Commit ed23c481 authored by Budiardja, Reuben's avatar Budiardja, Reuben
Browse files

Allocator with Pinned trait test program.

parent 64fd682d
program OpenMP_PinnedAllocation
use omp_lib
use iso_fortran_env
implicit none
integer, parameter :: &
N_VALUES = 256 ** 3, &
N_VARIABLES = 20
real ( real64 ) :: &
TimeStart, &
TimeStop
real ( real64 ), dimension ( :, : ), allocatable :: &
A_Pinned, &
A_NonPinned
integer ( omp_allocator_handle_kind ) :: &
OMP_AllocHandle
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 ] )
!$OMP allocate ( A_Pinned ) allocator ( OMP_AllocHandle )
allocate ( &
A_Pinned ( N_VALUES, N_VARIABLES ), &
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment