Skip to content

Commit 9605ac3

Browse files
committed
more
1 parent e0c53f6 commit 9605ac3

File tree

5 files changed

+101
-84
lines changed

5 files changed

+101
-84
lines changed

pluto/src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ if (HAVE_FORTRAN)
123123
pluto_f/pluto_module_memory_resource.F90
124124
pluto_f/pluto_module_allocate_deallocate.F90
125125
pluto_f/pluto_module_allocator.F90
126+
pluto_f/pluto_module_scope.F90
127+
pluto_f/pluto_module_trace.F90
126128
pluto_f/pluto_module.F90
127129
PRIVATE_LIBS pluto
128130
PUBLIC_INCLUDES $<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}>

pluto/src/pluto_f/pluto_module.F90

Lines changed: 10 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ module pluto_module
2929
pluto_register_resource, &
3030
pluto_unregister_resource
3131
use pluto_module_allocator, only : &
32-
pluto_allocator
32+
pluto_allocator, &
33+
pluto_make_allocator_name, &
34+
pluto_make_allocator_type
3335
use pluto_module_allocate_deallocate, only : &
3436
pluto_allocate, pluto_deallocate
37+
use pluto_module_scope, only : &
38+
pluto_scope_t
39+
use pluto_module_trace, only : &
40+
pluto_trace_t
3541

3642
implicit none
3743
private
3844

3945
public :: pluto, pluto_memory_resource, pluto_allocator
4046

41-
type :: pluto_trace_t
42-
contains
43-
procedure, nopass :: enable => pluto_trace_enable
44-
procedure, nopass :: enabled => pluto_trace_enabled
45-
end type
46-
4747
type pluto_host_t
4848
integer :: dummy
4949
contains
@@ -121,12 +121,6 @@ module pluto_module
121121

122122
end type
123123

124-
type pluto_scope_t
125-
contains
126-
procedure, nopass :: push => pluto_scope_push
127-
procedure, nopass :: pop => pluto_scope_pop
128-
end type
129-
130124
type pluto_t
131125
type(pluto_host_t) :: host
132126
type(pluto_device_t) :: device
@@ -149,9 +143,9 @@ module pluto_module
149143
procedure, nopass :: device_pool_resource => pluto_device_pool_resource
150144
procedure, nopass :: managed_pool_resource => pluto_managed_pool_resource
151145

152-
procedure, private :: make_allocator_type => pluto_make_allocator_type
153-
procedure, private :: make_allocator_name => pluto_make_allocator_name
154-
generic :: make_allocator => make_allocator_type, make_allocator_name
146+
procedure, nopass, private :: pluto_make_allocator_type
147+
procedure, nopass, private :: pluto_make_allocator_name
148+
generic :: make_allocator => pluto_make_allocator_type, pluto_make_allocator_name
155149

156150
procedure, private ,nopass :: reserve_int32 => pluto_memory_pool_resource_reserve_int32
157151
procedure, private ,nopass :: reserve_int64 => pluto_memory_pool_resource_reserve_int64
@@ -219,60 +213,6 @@ module pluto_module
219213

220214
contains
221215

222-
223-
subroutine pluto_scope_push()
224-
interface
225-
subroutine c_pluto_scope_push() bind(c)
226-
end subroutine
227-
end interface
228-
call c_pluto_scope_push()
229-
end subroutine
230-
231-
subroutine pluto_scope_pop()
232-
interface
233-
subroutine c_pluto_scope_pop() bind(c)
234-
end subroutine
235-
end interface
236-
call c_pluto_scope_pop()
237-
end subroutine
238-
239-
subroutine pluto_trace_enable(enable)
240-
logical, optional :: enable
241-
logical :: do_enable
242-
interface
243-
subroutine c_pluto_trace_enable(enable) bind(c)
244-
use iso_c_binding, only: c_int
245-
integer(c_int), value :: enable
246-
end subroutine
247-
end interface
248-
do_enable = .true.
249-
if (present(enable)) then
250-
do_enable = enable
251-
endif
252-
if (do_enable) then
253-
call c_pluto_trace_enable(1_c_int)
254-
else
255-
call c_pluto_trace_enable(0_c_int)
256-
endif
257-
end subroutine
258-
259-
function pluto_trace_enabled()
260-
logical :: pluto_trace_enabled
261-
integer(c_int) :: enabled
262-
interface
263-
function c_pluto_trace_enabled() result(enabled) bind(c)
264-
use iso_c_binding, only: c_int
265-
integer(c_int) :: enabled
266-
end function
267-
end interface
268-
enabled = c_pluto_trace_enabled()
269-
if (enabled == 1) then
270-
pluto_trace_enabled = .true.
271-
else
272-
pluto_trace_enabled = .false.
273-
endif
274-
end function
275-
276216
function pluto_devices()
277217
integer(c_int) :: pluto_devices
278218
interface
@@ -294,20 +234,6 @@ function pluto_device_make_allocator() result(allocator)
294234
allocator%memory_resource = pluto_device_get_default_resource()
295235
end function
296236

297-
function pluto_make_allocator_type(this, resource) result(allocator)
298-
class(pluto_t) :: this
299-
type(pluto_allocator) :: allocator
300-
type(pluto_memory_resource) :: resource
301-
allocator%memory_resource%c_memory_resource = resource%c_memory_resource
302-
end function
303-
304-
function pluto_make_allocator_name(this, resource) result(allocator)
305-
class(pluto_t) :: this
306-
type(pluto_allocator) :: allocator
307-
character(len=*), target, intent(in) :: resource
308-
allocator%memory_resource = pluto_get_registered_resource(resource)
309-
end function
310-
311237
subroutine pluto_allocate_int32_bounds_type(array, lbounds, ubounds, resource)
312238
integer(c_int32_t), pointer, intent(inout) :: array(..)
313239
integer(c_int), intent(in) :: lbounds(rank(array))

pluto/src/pluto_f/pluto_module_allocator.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module pluto_module_allocator
1414
private
1515

1616
public :: pluto_allocator
17+
public :: pluto_make_allocator_type
18+
public :: pluto_make_allocator_name
1719

1820
type pluto_allocator
1921
type(pluto_memory_resource) :: memory_resource
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module pluto_module_scope
2+
3+
implicit none
4+
private
5+
6+
public :: pluto_scope_t
7+
8+
type pluto_scope_t
9+
contains
10+
procedure, nopass :: push => pluto_scope_push
11+
procedure, nopass :: pop => pluto_scope_pop
12+
end type
13+
14+
contains
15+
16+
subroutine pluto_scope_push()
17+
interface
18+
subroutine c_pluto_scope_push() bind(c)
19+
end subroutine
20+
end interface
21+
call c_pluto_scope_push()
22+
end subroutine
23+
24+
subroutine pluto_scope_pop()
25+
interface
26+
subroutine c_pluto_scope_pop() bind(c)
27+
end subroutine
28+
end interface
29+
call c_pluto_scope_pop()
30+
end subroutine
31+
32+
end module
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module pluto_module_trace
2+
3+
implicit none
4+
private
5+
6+
public :: pluto_trace_t
7+
8+
type :: pluto_trace_t
9+
contains
10+
procedure, nopass :: enable => pluto_trace_enable
11+
procedure, nopass :: enabled => pluto_trace_enabled
12+
end type
13+
14+
contains
15+
16+
subroutine pluto_trace_enable(enable)
17+
use iso_c_binding, only: c_int
18+
logical, optional :: enable
19+
logical :: do_enable
20+
interface
21+
subroutine c_pluto_trace_enable(enable) bind(c)
22+
use iso_c_binding, only: c_int
23+
integer(c_int), value :: enable
24+
end subroutine
25+
end interface
26+
do_enable = .true.
27+
if (present(enable)) then
28+
do_enable = enable
29+
endif
30+
if (do_enable) then
31+
call c_pluto_trace_enable(1_c_int)
32+
else
33+
call c_pluto_trace_enable(0_c_int)
34+
endif
35+
end subroutine
36+
37+
function pluto_trace_enabled()
38+
use iso_c_binding, only: c_int
39+
logical :: pluto_trace_enabled
40+
integer(c_int) :: enabled
41+
interface
42+
function c_pluto_trace_enabled() result(enabled) bind(c)
43+
use iso_c_binding, only: c_int
44+
integer(c_int) :: enabled
45+
end function
46+
end interface
47+
enabled = c_pluto_trace_enabled()
48+
if (enabled == 1) then
49+
pluto_trace_enabled = .true.
50+
else
51+
pluto_trace_enabled = .false.
52+
endif
53+
end function
54+
55+
end module

0 commit comments

Comments
 (0)