Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Budiardja, Reuben
Fortran Frontier
Commits
ea1d7c19
Commit
ea1d7c19
authored
Oct 04, 2021
by
Budiardja, Reuben
Browse files
Pinned allocation with omp_alloc() routine.
parent
dff36bce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Cases/Composite/OpenMP_Allocator/OpenMP_PinnedAllocation.f90
→
Cases/Composite/OpenMP_Allocator/OpenMP_PinnedAllocation
Directive
.f90
View file @
ea1d7c19
...
...
@@ -7,7 +7,7 @@ program OpenMP_PinnedAllocation
integer
,
parameter
::
&
N_VALUES
=
256
**
3
,
&
N_VARIABLES
=
2
0
N_VARIABLES
=
4
0
real
(
real64
)
::
&
TimeStart
,
&
TimeStop
...
...
Cases/Composite/OpenMP_Allocator/OpenMP_PinnedAllocationRoutine.f90
0 → 100644
View file @
ea1d7c19
program
OpenMP_PinnedAllocation
use
omp_lib
use
iso_fortran_env
use
iso_c_binding
implicit
none
integer
,
parameter
::
&
N_VALUES
=
256
**
3
,
&
N_VARIABLES
=
40
real
(
real64
)
::
&
TimeStart
,
&
TimeStop
real
(
real64
),
dimension
(
:,
:
),
pointer
::
&
A_Pinned
,
&
A_NonPinned
integer
(
omp_allocator_handle_kind
)
::
&
OMP_AllocHandle
type
(
c_ptr
)
::
&
A_Pinned_C_Ptr
type
(
omp_alloctrait
)
::
&
OMP_TraitHandle
=
omp_alloctrait
(
omp_atk_pinned
,
omp_atv_true
)
OMP_AllocHandle
&
=
omp_init_allocator
(
omp_default_mem_space
,
1
,
[
OMP_TraitHandle
]
)
!-- Pinned allocation
A_Pinned_C_Ptr
&
=
omp_alloc
(
c_sizeof
(
1.0_real64
)
*
N_VALUES
*
N_VARIABLES
,
&
OMP_AllocHandle
)
call
c_f_pointer
(
A_Pinned_C_Ptr
,
A_Pinned
,
[
N_VALUES
,
N_VARIABLES
]
)
allocate
(
A_NonPinned
(
N_VALUES
,
N_VARIABLES
)
)
!$OMP target enter data map ( alloc : A_Pinned, A_NonPinned )
call
random_number
(
A_Pinned
)
call
random_number
(
A_NonPinned
)
TimeStart
=
omp_get_wtime
(
)
!$OMP target update to ( A_Pinned )
!$OMP barrier
TimeStop
=
omp_get_wtime
(
)
print
*
,
'Pinned timing (s) :'
,
TimeStop
-
TimeStart
TimeStart
=
omp_get_wtime
(
)
!$OMP target update to ( A_NonPinned )
!$OMP barrier
TimeStop
=
omp_get_wtime
(
)
print
*
,
'NonPinned timing (s) :'
,
TimeStop
-
TimeStart
end
program
OpenMP_PinnedAllocation
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment