Octopus
alloc_cache.F90
Go to the documentation of this file.
1!! Copyright (C) 2019 X. Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the Lesser GNU General Public License as published by
5!! the Free Software Foundation; either version 3, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21
23 use global_oct_m
24 use iso_c_binding
25 use, intrinsic :: iso_fortran_env
26
27 implicit none
28
29 private
30
31 public :: &
37
38 type alloc_cache_t
39 private
40 integer(int64) :: dummy
41 end type alloc_cache_t
42
43 integer(int64), public, parameter :: &
44 ALLOC_CACHE_ANY_SIZE = -1_8
45
46 interface
47
48 subroutine alloc_cache_init(alloc_cache, max_size)
49 use, intrinsic :: iso_fortran_env
50 import :: alloc_cache_t
51 implicit none
52
53 type(alloc_cache_t), intent(out) :: alloc_cache
54 integer(int64), intent(in) :: max_size
55 end subroutine alloc_cache_init
56
57 ! -------------------------------------------------
58
59 subroutine alloc_cache_end(alloc_cache, hits, misses, vol_hits, vol_misses)
60 use iso_c_binding
61 use, intrinsic :: iso_fortran_env
62 import :: alloc_cache_t
63 implicit none
64
65 type(alloc_cache_t), intent(inout) :: alloc_cache
66 integer(int64), intent(out) :: hits
67 integer(int64), intent(out) :: misses
68 real(c_double), intent(out) :: vol_hits
69 real(c_double), intent(out) :: vol_misses
70 end subroutine alloc_cache_end
71
72 end interface
73
74contains
75
76 subroutine alloc_cache_put(alloc_cache, size, loc, put)
77 type(alloc_cache_t), intent(inout) :: alloc_cache
78 integer(int64), intent(in) :: size
79 type(c_ptr), intent(in) :: loc
80 logical, intent(out) :: put
81
82 interface
83 subroutine alloc_cache_put_low(alloc_cache, size, loc, put)
84 use iso_c_binding
85 use, intrinsic :: iso_fortran_env
86 import :: alloc_cache_t
87 implicit none
88
89 type(alloc_cache_t), intent(inout) :: alloc_cache
90 integer(int64), intent(in) :: size
91 type(c_ptr), intent(in) :: loc
92 integer, intent(out) :: put
93 end subroutine alloc_cache_put_low
94 end interface
95
96 integer :: iput
97
98 call alloc_cache_put_low(alloc_cache, size, loc, iput)
99
100 put = (iput /= 0)
101
102 end subroutine alloc_cache_put
103
104 ! -------------------------------------------------
105
106 subroutine alloc_cache_get(alloc_cache, size, found, loc)
107 type(alloc_cache_t), intent(inout) :: alloc_cache
108 integer(int64), intent(in) :: size
109 logical, intent(out) :: found
110 type(c_ptr), intent(out) :: loc
111
112 interface
113 subroutine alloc_cache_get_low(alloc_cache, size, found, loc)
114 use iso_c_binding
115 use, intrinsic :: iso_fortran_env
116 import :: alloc_cache_t
117 implicit none
118
119 type(alloc_cache_t), intent(inout) :: alloc_cache
120 integer(int64), intent(in) :: size
121 integer, intent(out) :: found
122 type(c_ptr), intent(out) :: loc
123 end subroutine alloc_cache_get_low
124 end interface
125
126 integer :: ifound
127
128 call alloc_cache_get_low(alloc_cache, size, ifound, loc)
129
130 found = (ifound /= 0)
131
132 end subroutine alloc_cache_get
134
136
137!! Local Variables:
138!! mode: f90
139!! coding: utf-8
140!! End:
subroutine, public alloc_cache_put(alloc_cache, size, loc, put)
subroutine, public alloc_cache_get(alloc_cache, size, found, loc)