30 use iso_c_binding,
only: c_null_ptr, c_size_t
31 use,
intrinsic :: iso_fortran_env
90 integer,
public,
parameter :: &
91 ACCEL_MEM_READ_ONLY = 0, &
98 type(c_ptr) :: cuda_context
106#if defined(HAVE_CUDA)
107 type(c_ptr) :: cuda_device
115 type(accel_context_t) :: context
116 type(accel_device_t) :: device
117 type(c_ptr) :: cuda_stream
118 type(c_ptr) :: program_map
119 integer :: max_block_size
120 integer(int64) :: shared_memory_size
121 integer(int64) :: global_memory_size
123 logical :: allow_CPU_only
126 integer(int64) :: initialize_buffers
127 character(len=32) :: debug_flag
128 integer(int64) :: max_block_dim(3)
129 integer(int64) :: max_grid_dim(3)
135 integer(c_size_t) :: size = 0
138 logical :: allocated = .false.
144 type(c_ptr) :: cuda_kernel
145 type(c_ptr) :: arguments
147 logical :: initialized = .false.
148 type(accel_kernel_t),
pointer :: next
150 character(len=128) :: kernel_name
153 type(accel_t),
public :: accel
156 type(accel_kernel_t),
public,
target,
save :: kernel_vpsi
157 type(accel_kernel_t),
public,
target,
save :: kernel_vpsi_complex
158 type(accel_kernel_t),
public,
target,
save :: kernel_vpsi_spinors
159 type(accel_kernel_t),
public,
target,
save :: kernel_vpsi_spinors_complex
160 type(accel_kernel_t),
public,
target,
save :: kernel_daxpy
161 type(accel_kernel_t),
public,
target,
save :: kernel_zaxpy
162 type(accel_kernel_t),
public,
target,
save :: kernel_copy
163 type(accel_kernel_t),
public,
target,
save :: kernel_copy_complex_to_real
164 type(accel_kernel_t),
public,
target,
save :: kernel_copy_real_to_complex
165 type(accel_kernel_t),
public,
target,
save :: dpack
166 type(accel_kernel_t),
public,
target,
save :: zpack
167 type(accel_kernel_t),
public,
target,
save :: dunpack
168 type(accel_kernel_t),
public,
target,
save :: zunpack
169 type(accel_kernel_t),
public,
target,
save :: kernel_ghost_reorder
170 type(accel_kernel_t),
public,
target,
save :: kernel_density_real
171 type(accel_kernel_t),
public,
target,
save :: kernel_density_complex
172 type(accel_kernel_t),
public,
target,
save :: kernel_density_spinors
173 type(accel_kernel_t),
public,
target,
save :: kernel_phase
174 type(accel_kernel_t),
public,
target,
save :: kernel_phase_spiral
175 type(accel_kernel_t),
public,
target,
save :: zkernel_dot_matrix_spinors
176 type(accel_kernel_t),
public,
target,
save :: dzmul_batch
177 type(accel_kernel_t),
public,
target,
save :: zzmul_batch
278 enabled = accel%enabled
288 allow = accel%allow_CPU_only
297 type(mpi_grp_t),
intent(inout) :: base_grp
298 type(namespace_t),
intent(in) :: namespace
300 logical :: disable, default, run_benchmark
305 character(len=256) :: sys_name
329 accel%enabled = .not. disable
332 if (accel%enabled)
then
333 message(1) =
'Octopus was compiled without Cuda support.'
361 if (idevice < 0)
then
369 if (idevice<0) idevice = 0
370 call cuda_init(accel%context%cuda_context, accel%device%cuda_device, accel%cuda_stream, &
371 idevice, base_grp%rank)
374 write(
message(1),
'(A,I5,A,I5,2A)')
"Rank ", base_grp%rank,
" uses device number ", idevice, &
375 " on ", trim(sys_name)
390 accel%max_block_dim(1) = int(dim, int64)
392 accel%max_block_dim(2) = int(dim, int64)
394 accel%max_block_dim(3) = int(dim, int64)
396 accel%max_grid_dim(1) = int(dim, int64)
398 accel%max_grid_dim(2) = int(dim, int64)
400 accel%max_grid_dim(3) = int(dim, int64)
412 accel%debug_flag =
"-g"
413#elif defined(HAVE_CUDA)
414 accel%debug_flag =
"-lineinfo"
450 call parse_variable(namespace,
'AccelBenchmark', .false., run_benchmark)
454 if (run_benchmark)
then
475 call parse_variable(namespace,
'GPUAwareMPI', default, accel%cuda_mpi)
476 if (accel%cuda_mpi)
then
478 call messages_write(
"Warning: trying to use GPU-aware MPI, but we have not detected support in the linked MPI library.")
494#if defined (HAVE_ACCEL)
499 call parse_variable(namespace,
'AllowCPUonly', default, accel%allow_CPU_only)
515 call parse_variable(namespace,
'InitializeGPUBuffers', option__initializegpubuffers__no, accel%initialize_buffers)
530 character(kind=c_char) :: cval_str(257)
532 integer :: major, minor
533 character(len=256) :: val_str
542#ifdef __HIP_PLATFORM_AMD__
552#ifdef __HIP_PLATFORM_AMD__
560 cval_str = c_null_char
608 integer(int64) :: hits, misses
609 real(real64) :: volume_hits, volume_misses
621 if (.not. found)
exit
639 if (hits + misses > 0)
then
640 call messages_write(hits/real(hits + misses, real64)*100, fmt=
'(f6.1)', align_left = .
true.)
646 if (volume_hits + volume_misses > 0)
then
647 call messages_write(volume_hits/(volume_hits + volume_misses)*100, fmt=
'(f6.1)', align_left = .
true.)
663 if (.not. accel%cuda_mpi)
then
664 call cuda_end(accel%context%cuda_context, accel%device%cuda_device)
686 integer(int64),
intent(in) :: n(:)
687 integer(int64),
intent(in) :: blocksizes(:)
688 integer(int64),
intent(out) :: gridsizes(:)
692 dim = ubound(n, dim=1)
693 assert(dim == ubound(blocksizes, dim=1))
694 assert(dim == ubound(gridsizes, dim=1))
697 gridsizes(i) = (n(i) + blocksizes(i) - 1_int64) / blocksizes(i)
698 gridsizes(i) = min(gridsizes(i), accel%max_grid_dim(i))
706 integer,
intent(in) :: n(:)
707 integer,
intent(in) :: blocksizes(:)
708 integer,
intent(out) :: gridsizes(:)
710 integer(int64) :: gridsizes64(size(gridsizes))
714 gridsizes = int(gridsizes64, int32)
721 integer(int64),
intent(in) :: n
722 integer(int64),
intent(in) :: blocksizes
723 integer(int64),
intent(out) :: gridsizes
725 integer(int64) :: temp(1)
736 integer,
intent(in) :: n
737 integer,
intent(in) :: blocksizes
738 integer,
intent(out) :: gridsizes
740 integer(int64) :: temp(1)
744 gridsizes = int(temp(1), int32)
753 integer(int64),
intent(in) :: n
754 integer(int64),
intent(in) :: pack_size
755 integer(int64),
dimension(3),
intent(out) :: gridsizes
756 integer(int64),
dimension(3),
intent(out) :: blocksizes
759 integer(int64) :: bsize, dim2, dim3
760 integer(int64),
dimension(3) :: nn
762 if(
present(kernel))
then
771 nn = (/pack_size, dim2, dim3/)
772 blocksizes = (/pack_size, bsize, 1_int64/)
783 integer,
intent(in) :: n
784 integer,
intent(in) :: pack_size
785 integer,
dimension(3),
intent(out) :: gridsizes
786 integer,
dimension(3),
intent(out) :: blocksizes
789 integer(int64) :: gridsizes64(3), blocksizes64(3)
792 gridsizes64, blocksizes64, kernel=kernel)
794 gridsizes = int(gridsizes64, int32)
795 blocksizes = int(blocksizes64, int32)
801 integer(int64),
intent(in) :: nn
803 integer(int64) :: modnn, bsize
812 modnn = mod(nn, bsize)
813 if (modnn /= 0) psize = psize + bsize - modnn
822 integer(int32),
intent(in) :: nn
832 integer,
intent(in) :: flags
833 type(
type_t),
intent(in) :: type
834 integer,
intent(in) :: size
835 logical,
optional,
intent(in) :: set_zero
836 logical,
optional,
intent(in) :: async
845 integer,
intent(in) :: flags
846 type(
type_t),
intent(in) :: type
847 integer(int64),
intent(in) :: size
848 logical,
optional,
intent(in) :: set_zero
849 logical,
optional,
intent(in) :: async
851 integer(int64) :: fsize
853 integer(int64) :: initialize_buffers
861 this%allocated = .
true.
867 if (.not. found)
then
882 if (
present(set_zero))
then
883 initialize_buffers = merge(option__initializegpubuffers__yes, option__initializegpubuffers__no, set_zero)
885 initialize_buffers = accel%initialize_buffers
887 select case (initialize_buffers)
888 case (option__initializegpubuffers__yes)
890 case (option__initializegpubuffers__nan)
901 logical,
optional,
intent(in) :: async
904 integer(int64) :: fsize
908 if (this%size > 0)
then
932 this%allocated = .false.
951 buffer_to%mem = buffer_from%mem
952 buffer_to%size = buffer_from%size
953 buffer_to%type = buffer_from%type
954 buffer_to%flags = buffer_from%flags
955 buffer_to%allocated = buffer_from%allocated
973 this%mem = c_null_ptr
977 this%allocated = .false.
987 integer,
intent(in) :: flags
988 type(
type_t),
intent(in) :: type
989 integer,
intent(in) :: required_size
990 logical,
intent(in) :: set_zero
991 logical,
optional,
intent(in) :: async
1012 allocated = this%allocated
1031 integer,
intent(in) :: narg
1053 integer(int64),
intent(in) :: gridsizes(:)
1054 integer(int64),
intent(in) :: blocksizes(:)
1055 integer(int64),
optional,
intent(in) :: shared_memory_size
1058 integer(int64) :: gsizes(1:3)
1059 integer(int64) :: bsizes(1:3)
1067 dim = ubound(gridsizes, dim=1)
1069 assert(dim == ubound(blocksizes, dim=1))
1072 if (any(gridsizes == 0))
return
1074 assert(all(blocksizes > 0))
1076 gsizes(1:dim) = gridsizes(1:dim)
1077 bsizes(1:dim) = blocksizes(1:dim)
1081 if (any(bsizes(1:3) > accel%max_block_dim(1:3)))
then
1082 message(1) =
"Maximum dimension of a block too large in kernel "//trim(kernel%kernel_name)
1083 message(2) =
"The following conditions should be fulfilled:"
1084 write(
message(3),
"(A, I8, A, I8)")
"Dim 1: ", bsizes(1),
" <= ", accel%max_block_dim(1)
1085 write(
message(4),
"(A, I8, A, I8)")
"Dim 2: ", bsizes(2),
" <= ", accel%max_block_dim(2)
1086 write(
message(5),
"(A, I8, A, I8)")
"Dim 3: ", bsizes(3),
" <= ", accel%max_block_dim(3)
1087 message(6) =
"This is an internal error, please contact the developers."
1094 message(1) =
"Maximum number of threads per block too large in kernel "//trim(kernel%kernel_name)
1095 message(2) =
"The following condition should be fulfilled:"
1097 message(4) =
"This is an internal error, please contact the developers."
1102 if (any(gsizes(1:3) > accel%max_grid_dim(1:3)))
then
1103 message(1) =
"Maximum dimension of grid too large in kernel "//trim(kernel%kernel_name)
1104 message(2) =
"The following conditions should be fulfilled:"
1105 write(
message(3),
"(A, I8, A, I10)")
"Dim 1: ", gsizes(1),
" <= ", accel%max_grid_dim(1)
1106 write(
message(4),
"(A, I8, A, I10)")
"Dim 2: ", gsizes(2),
" <= ", accel%max_grid_dim(2)
1107 write(
message(5),
"(A, I8, A, I10)")
"Dim 3: ", gsizes(3),
" <= ", accel%max_grid_dim(3)
1108 message(6) =
"This is an internal error, please contact the developers."
1112 if(
present(shared_memory_size))
then
1114 if (shared_memory_size > accel%shared_memory_size)
then
1115 message(1) =
"Shared memory too large in kernel "//trim(kernel%kernel_name)
1116 message(2) =
"The following condition should be fulfilled:"
1117 message(3) =
"Requested shared memory <= Available shared memory"
1118 write(
message(4),
'(a,f12.6,a)')
"Requested shared memory: ", real(shared_memory_size, real64) /1024.0,
" Kb"
1119 write(
message(5),
'(a,f12.6,a)')
"Available shared memory: ", real(accel%shared_memory_size, real64) /1024.0,
" Kb"
1120 message(6) =
"This is an internal error, please contact the developers."
1122 else if (shared_memory_size <= 0)
then
1123 message(1) =
"Invalid shared memory size in kernel "//trim(kernel%kernel_name)
1124 write(
message(2),
'(a,f12.6,a)')
"Shared memory size requested: ", real(shared_memory_size, real64) /1024.0,
" Kb"
1125 message(3) =
"This is an internal error, please contact the developers."
1146 integer,
intent(in) :: gridsizes(:)
1147 integer,
intent(in) :: blocksizes(:)
1148 integer(int64),
optional,
intent(in) :: shared_memory_size
1150 call accel_kernel_run_8(kernel, int(gridsizes, int64), int(blocksizes, int64), shared_memory_size)
1157 max_block_size = accel%max_block_size
1166 integer :: max_block_size
1172 call cuda_kernel_max_threads_per_block(kernel%cuda_kernel, max_block_size)
1173 if (debug%info .and. max_block_size /=
accel%max_block_size)
then
1174 write(message(1),
"(A, I5, A)")
"A kernel can use only less threads per block (", max_block_size,
")", &
1175 "than available on the device (",
accel%max_block_size,
")"
1176 call messages_info(1)
1184 block_size = min(block_size, max_block_size)
1192 subroutine accel_copy_buffer(dest, src, type, nval, offset_dest, offset_src, async)
1195 type(type_t),
intent(in) :: type
1196 integer(int64),
intent(in) :: nval
1197 integer(int64),
optional,
intent(in) :: offset_dest
1198 integer(int64),
optional,
intent(in) :: offset_src
1199 logical,
optional,
intent(in) :: async
1201 integer(int64) :: type_size, offset_dest_, offset_src_
1204 call profiling_in(
"ACCEL_COPY_BUFFER")
1207 call profiling_out(
"ACCEL_COPY_BUFFER")
1213 type_size = types_get_size(type)
1215 offset_dest_ = 0_int64
1216 if (
present(offset_dest)) offset_dest_ = offset_dest*type_size
1217 offset_src_ = 0_int64
1218 if (
present(offset_src)) offset_src_ = offset_src*type_size
1220 assert(offset_dest_ + nval*type_size <= int(dest%size, int64)*types_get_size(dest%type))
1221 assert(offset_src_ + nval*type_size <= int(src%size, int64)*types_get_size(src%type))
1223 call cuda_memcpy_dtod(dest%mem, src%mem, nval*type_size, offset_dest_, offset_src_)
1225 if (.not. optional_default(async, .false.))
call accel_finish()
1227 call profiling_out(
"ACCEL_COPY_BUFFER")
1235 type(type_t),
intent(in) :: type
1236 integer(int8),
intent(in) :: val
1237 integer(int64),
intent(in) :: nval
1238 integer(int64),
optional,
intent(in) :: offset
1239 logical,
optional,
intent(in) :: async
1241 integer(int64) :: nval_, offset_, type_size
1251 if (
present(offset))
then
1253 if(offset > buffer%size)
then
1259 type_size = types_get_size(type)
1261 nval_ = nval*type_size
1264 if (
present(offset)) offset_ = offset*type_size
1266 call cuda_mem_set_async(buffer%mem, val, nval_, offset_)
1267 if(.not. optional_default(async, .false.))
call accel_finish()
1276 type(type_t),
intent(in) :: type
1277 integer(int64),
intent(in) :: nval
1278 integer(int64),
optional,
intent(in) :: offset
1279 logical,
optional,
intent(in) :: async
1292 type(type_t),
intent(in) :: type
1293 integer(int32),
intent(in) :: nval
1294 integer(int32),
optional,
intent(in) :: offset
1295 logical,
optional,
intent(in) :: async
1299 if (
present(offset))
then
1312 integer,
parameter :: times = 10
1314 real(real64) :: time, stime
1315 real(real64) :: read_bw, write_bw
1317 real(real64),
allocatable :: data(:)
1319 call messages_new_line()
1320 call messages_write(
'Info: Benchmarking the bandwidth between main memory and device memory')
1321 call messages_new_line()
1322 call messages_info()
1324 call messages_write(
' Buffer size Read bw Write bw')
1325 call messages_new_line()
1326 call messages_write(
' [MiB] [MiB/s] [MiB/s]')
1327 call messages_info()
1331 safe_allocate(
data(1:size))
1334 stime = loct_clock()
1339 time = (loct_clock() - stime)/real(times, real64)
1341 write_bw = real(
size, real64) *8.0_real64/time
1343 stime = loct_clock()
1349 time = (loct_clock() - stime)/real(times, real64)
1350 read_bw = real(
size, real64) *8.0_real64/time
1352 call messages_write(size*8.0_real64/1024.0_real64**2)
1353 call messages_write(write_bw/1024.0_real64**2, fmt =
'(f10.1)')
1354 call messages_write(read_bw/1024.0_real64**2, fmt =
'(f10.1)')
1355 call messages_info()
1359 safe_deallocate_a(data)
1361 size = int(size*2.0)
1363 if (
size > 50000000)
exit
1375 call cuda_program_map_init(
accel%program_map)
1408 'batch_axpy_function<double, DimSpin::D1>')
1410 'batch_axpy_function<double, DimSpin::D2>')
1412 'batch_axpy_function<complex<double>, DimSpin::D1>')
1414 'batch_axpy_function<complex<double>, DimSpin::D2>')
1416 'batch_ax_function_py<double, DimSpin::D1>')
1418 'batch_ax_function_py<double, DimSpin::D2>')
1420 'batch_ax_function_py<complex<double>, DimSpin::D1>')
1422 'batch_ax_function_py<complex<double>, DimSpin::D2>')
1426 call accel_program_add(
'batch_mul.cu',
'mul_batch<complex<double>, Conjugation::No>')
1427 call accel_program_add(
'batch_mul.cu',
'mul_batch<complex<double>, Conjugation::Yes>')
1428 call accel_program_add(
'batch_mul.cu',
'mul_mf<complex<double>, double, Conjugation::No>')
1429 call accel_program_add(
'batch_mul.cu',
'mul_mf<complex<double>, double, Conjugation::Yes>')
1430 call accel_program_add(
'batch_mul.cu',
'mul_mf<complex<double>, complex<double>, Conjugation::No>')
1431 call accel_program_add(
'batch_mul.cu',
'mul_mf<complex<double>, complex<double>, Conjugation::Yes>')
1436 call accel_program_add(
'boundaries.cu',
'boundaries_periodic_recv_corr<double>')
1454 'dftu_pos_mat_elem<double, double, Indexing::Indirect>')
1456 'dftu_pos_mat_elem<double, complex<double>, Indexing::Indirect>')
1458 'dftu_pos_mat_elem<double, complex<double>, Indexing::Direct>')
1461 'dftu_pos_mat_elem<double, double, Indexing::Direct>')
1463 'dftu_projector_bra<double>')
1465 'dftu_projector_bra<complex<double>>')
1467 'dftu_projector_bra_submesh<complex<double>>')
1469 'dftu_projector_bra_submesh<double>')
1471 'dftu_projector_ket<double>')
1473 'dftu_projector_ket<complex<double>>')
1475 'dftu_projector_ket_submesh<complex<double>>')
1477 'dftu_projector_ket_submesh<double>')
1480 'exchange_accumulate_batch<double, double, DimSpin::D1>')
1482 'exchange_accumulate_return_batch<double, double, DimSpin::D1>')
1484 'exchange_codensity_batch<double, DimSpin::D1>')
1486 'exchange_accumulate_batch<double, double, DimSpin::D2>')
1488 'exchange_accumulate_return_batch<double, double, DimSpin::D2>')
1490 'exchange_codensity_batch<double, DimSpin::D2>')
1492 'exchange_accumulate_batch<double, complex<double>, DimSpin::D1>')
1494 'exchange_accumulate_return_batch<double, complex<double>, DimSpin::D1>')
1496 'exchange_codensity_batch<complex<double>, DimSpin::D1>')
1498 'exchange_accumulate_batch<double, complex<double>, DimSpin::D2>')
1500 'exchange_accumulate_return_batch<double, complex<double>, DimSpin::D2>')
1502 'exchange_codensity_batch<complex<double>, DimSpin::D2>')
1505 call accel_program_add(
'forces.cu',
'density_gradient<double, complex<double>>')
1515 'batch_dotpv_reduce<double, double, DimSpin::D1>')
1517 'batch_dotpv_reduce<double, double, DimSpin::D2>')
1519 'batch_mf_dotp<double, DimSpin::D1>')
1521 'batch_mf_dotp<double, DimSpin::D2>')
1522 call accel_program_add(
'mesh_batch_single.cu',
'batch_dotpv_partial<complex<double>>')
1524 'batch_dotpv_reduce<double, complex<double>, DimSpin::D1>')
1526 'batch_dotpv_reduce<double, complex<double>, DimSpin::D2>')
1528 'batch_mf_dotp<complex<double>, DimSpin::D1>')
1530 'batch_mf_dotp<complex<double>, DimSpin::D2>')
1533 'mesh_interpolate<double, double, Dim::D1>')
1535 'mesh_interpolate<double, double, Dim::D2>')
1537 'mesh_interpolate<double, double, Dim::D3>')
1539 'mesh_interpolate<double, complex<double>, Dim::D1>')
1541 'mesh_interpolate<double, complex<double>, Dim::D2>')
1543 'mesh_interpolate<double, complex<double>, Dim::D3>')
1547 call accel_program_add(
'mesh_to_cube.cu',
'cube_to_mesh_batch<complex<double>>')
1548 call accel_program_add(
'mesh_to_cube.cu',
'mesh_to_cube_batch<complex<double>>')
1556 call accel_program_add(
'operate.cu',
'operate_map<double, Indexing::Direct, Symmetry::Antisymmetric>')
1557 call accel_program_add(
'operate.cu',
'operate_map<double, Indexing::Direct, Symmetry::Symmetric>')
1558 call accel_program_add(
'operate.cu',
'operate_map<double, Indexing::Indirect, Symmetry::Antisymmetric>')
1559 call accel_program_add(
'operate.cu',
'operate_map<double, Indexing::Indirect, Symmetry::Symmetric>')
1588 call accel_program_add(
'projector.cu',
'projector_bra_force_phase<double, double>')
1590 call accel_program_add(
'projector.cu',
'projector_bra_scatter_real<double, double>')
1593 call accel_program_add(
'projector.cu',
'projector_ket_phase_spiral<double, double>')
1596 call accel_program_add(
'projector.cu',
'projector_r_vnl_bra_phase<double, double>')
1598 call accel_program_add(
'projector.cu',
'projector_r_vnl_ket_phase<double, double>')
1600 call accel_program_add(
'projector.cu',
'projector_bra_phase_spiral_gather<double>')
1601 call accel_program_add(
'projector.cu',
'projector_bra_force<double, complex<double>>')
1602 call accel_program_add(
'projector.cu',
'projector_bra_force_phase<double, complex<double>>')
1604 call accel_program_add(
'projector.cu',
'projector_bra_scatter_complex<double, complex<double>>')
1605 call accel_program_add(
'projector.cu',
'projector_bra_scatter_real<double, complex<double>>')
1607 call accel_program_add(
'projector.cu',
'projector_ket_phase<double, complex<double>>')
1608 call accel_program_add(
'projector.cu',
'projector_ket_phase_spiral<double, complex<double>>')
1610 call accel_program_add(
'projector.cu',
'projector_r_vnl_bra<double, complex<double>>')
1611 call accel_program_add(
'projector.cu',
'projector_r_vnl_bra_phase<double, complex<double>>')
1612 call accel_program_add(
'projector.cu',
'projector_r_vnl_ket<double, complex<double>>')
1613 call accel_program_add(
'projector.cu',
'projector_r_vnl_ket_phase<double, complex<double>>')
1615 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_bra<double, double>')
1616 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_bra_phase<double, double>')
1617 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_ket<double, double>')
1618 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_ket_phase<double, double>')
1619 call accel_program_add(
'projector_commutator.cu',
'dprojector_mix_commutator<double>')
1620 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_bra<double, complex<double>>')
1621 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_bra_phase<double, complex<double>>')
1622 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_ket<double, complex<double>>')
1623 call accel_program_add(
'projector_commutator.cu',
'projector_commutator_ket_phase<double, complex<double>>')
1624 call accel_program_add(
'projector_commutator.cu',
'zprojector_mix_commutator<double>')
1630 'symmetrizer_apply_single_batch<double, Conjugation::No>')
1632 'symmetrizer_apply_single_batch<double, Conjugation::Yes>')
1634 'symmetrizer_apply_single_batch<complex<double>, Conjugation::No>')
1636 'symmetrizer_apply_single_batch<complex<double>, Conjugation::Yes>')
1639 'uvw_to_xyz<double, Dim::D1, double*, int, double*, int>')
1641 'uvw_to_xyz<double, Dim::D2, double*, int, double*, int, double*, int, double*, int>')
1643 'uvw_to_xyz<double, Dim::D3, double*, int, double*, int, double*, int, double*, int, double*, int, double*, int>')
1664 character(len=*),
intent(in) :: file_name
1665 character(len=*),
intent(in) :: name
1669 call cuda_program_register(
accel%program_map, string_f_to_c(trim(file_name)), &
1670 string_f_to_c(trim(name)))
1683 if (.not.
associated(
head))
exit
1684 next_head =>
head%next
1690 call cuda_program_map_end(
accel%program_map)
1705 character(len=*),
intent(in) :: file_name
1706 character(len=*),
intent(in) :: kernel_name
1707 character(len=*),
optional,
intent(in) :: flags
1710 character(len=1000) :: all_flags
1715 call profiling_in(
"ACCEL_COMPILE", exclude = .
true.)
1718 all_flags =
'-I'//trim(conf%share)//
'/kernels/'//
" "//trim(
accel%debug_flag)
1720 if (
present(flags))
then
1721 all_flags = trim(all_flags)//
' '//trim(flags)
1724 call cuda_program_build(
accel%program_map,
accel%device%cuda_device, &
1725 string_f_to_c(trim(file_name)), string_f_to_c(trim(all_flags)))
1727 call cuda_program_get_kernel(this%cuda_kernel,
accel%program_map, &
1728 string_f_to_c(trim(file_name)), string_f_to_c(trim(all_flags)), &
1729 string_f_to_c(trim(kernel_name)))
1730 call cuda_alloc_arg_array(this%arguments)
1733 this%initialized = .
true.
1734 this%kernel_name = trim(kernel_name)
1736 call profiling_out(
"ACCEL_COMPILE")
1749 call cuda_free_arg_array(this%arguments)
1750 call cuda_release_kernel(this%cuda_kernel)
1754 this%initialized = .false.
1763 character(len=*),
intent(in) :: file_name
1764 character(len=*),
intent(in) :: kernel_name
1765 character(len=*),
optional,
intent(in) :: flags
1769 if (.not. this%initialized)
then
1782 size =
accel%global_memory_size
1790 size =
accel%shared_memory_size
1796 integer,
intent(in) :: dim
1801 if (dim == 1)
size = 2**30
1808 integer,
intent(in) :: stream_number
1814 call cuda_set_stream(
accel%cuda_stream, stream_number)
1817 call cublas_set_stream(
accel%cuda_stream, stream_number)
1827 integer,
intent(inout) :: stream_number
1833 call cuda_get_stream(stream_number)
1847 call cuda_synchronize_all_streams()
1855 type(c_ptr),
intent(in) :: buffer
1856 integer(int64),
intent(in) :: offset
1857 type(c_ptr) :: buffer_offset
1861 call cuda_get_pointer_with_offset(buffer, offset, buffer_offset)
1864 buffer_offset = buffer
1870 type(c_ptr),
intent(in) :: buffer
1871 integer(int64),
intent(in) :: offset
1872 type(c_ptr) :: buffer_offset
1876 call cuda_get_pointer_with_offset(buffer, 2_int64*offset, buffer_offset)
1879 buffer_offset = buffer
1885 type(c_ptr),
intent(in) :: buffer
1889 call cuda_clean_pointer(buffer)
1898 integer(int64),
intent(in) :: size
1899 integer(int64),
intent(out) :: grid_size
1900 integer(int64),
intent(out) :: thread_block_size
1903#ifdef __HIP_PLATFORM_AMD__
1906 thread_block_size =
size
1909 thread_block_size =
accel%warp_size
1916#include "accel_inc.F90"
1919#include "complex.F90"
1920#include "accel_inc.F90"
1923#include "integer.F90"
1924#include "accel_inc.F90"
1927#include "integer8.F90"
1928#include "accel_inc.F90"
subroutine accel_grid_size_i4(n, blocksizes, gridsizes)
Computes the grid size for a given problem size and block size (32-bit version).
subroutine laccel_get_device_pointer_3l(host_pointer, device_pointer, dimensions)
subroutine zaccel_get_device_pointer_2l(host_pointer, device_pointer, dimensions)
subroutine, public accel_clean_pointer(buffer)
subroutine accel_kernel_global_end()
subroutine zaccel_write_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine, public accel_get_unfolded_size(size, grid_size, thread_block_size)
Get unfolded size: some kernels (e.g. projectors) unfold the array across warps as an optimization....
subroutine laccel_read_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine laccel_read_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine iaccel_write_buffer_2(this, n1, n2, data, offset, async)
pure logical function, public accel_allow_cpu_only()
subroutine daccel_get_device_pointer_1(host_pointer, device_pointer, dimensions)
subroutine zaccel_read_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine daccel_read_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine zaccel_get_device_pointer_1(host_pointer, device_pointer, dimensions)
subroutine laccel_read_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine daccel_write_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine laccel_write_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine daccel_write_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine laccel_get_device_pointer_1(host_pointer, device_pointer, dimensions)
subroutine zaccel_read_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine zaccel_read_buffer_0(this, n1, data, offset, async)
integer function, public accel_kernel_block_size(kernel)
subroutine zaccel_write_buffer_single(this, data, async)
subroutine daccel_read_buffer_2(this, n1, n2, data, offset, async)
integer buffer_alloc_count
subroutine iaccel_get_device_pointer_3l(host_pointer, device_pointer, dimensions)
subroutine zaccel_read_buffer_2(this, n1, n2, data, offset, async)
subroutine laccel_get_device_pointer_2(host_pointer, device_pointer, dimensions)
subroutine iaccel_write_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine zaccel_write_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine accel_grid_size_array_i8(n, blocksizes, gridsizes)
Computes the grid size for a given problem size and block size (64-bit version).
subroutine laccel_write_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine zaccel_read_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine iaccel_write_buffer_1(this, n1, data, offset, async)
subroutine laccel_write_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine, public accel_free_buffer(this, async)
subroutine daccel_write_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine iaccel_write_buffer_0_int32(this, n1, data, offset, async)
subroutine, public accel_kernel_start_call(this, file_name, kernel_name, flags)
subroutine iaccel_write_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine zaccel_write_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine iaccel_read_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine zaccel_write_buffer_2_int32(this, n1, n2, data, offset, async)
subroutine, public accel_get_stream(stream_number)
subroutine accel_create_buffer_4(this, flags, type, size, set_zero, async)
subroutine zaccel_read_buffer_1_int32(this, n1, data, offset, async)
subroutine iaccel_write_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
integer(int64) pure function, public accel_global_memory_size()
subroutine daccel_read_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine laccel_write_buffer_1(this, n1, data, offset, async)
subroutine daccel_read_buffer_1(this, n1, data, offset, async)
subroutine daccel_write_buffer_2(this, n1, n2, data, offset, async)
subroutine zaccel_set_kernel_arg_data(kernel, narg, data)
subroutine daccel_get_device_pointer_3l(host_pointer, device_pointer, dimensions)
subroutine iaccel_read_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine daccel_get_device_pointer_2l(host_pointer, device_pointer, dimensions)
integer(int64) function accel_padded_size_i8(nn)
subroutine accel_check_bandwidth()
subroutine iaccel_write_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine daccel_read_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine laccel_read_buffer_0(this, n1, data, offset, async)
subroutine daccel_write_buffer_0(this, n1, data, offset, async)
subroutine zaccel_read_buffer_0_int32(this, n1, data, offset, async)
subroutine iaccel_get_device_pointer_1l(host_pointer, device_pointer, dimensions)
subroutine, public accel_finish()
subroutine laccel_write_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine accel_kernel_global_init()
subroutine zaccel_read_buffer_3_int32(this, n1, n2, n3, data, offset, async)
integer(int64) allocated_mem
subroutine daccel_read_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine accel_kernel_run_4(kernel, gridsizes, blocksizes, shared_memory_size)
Run a kernel with 4-byte integer sizes.
subroutine zaccel_write_buffer_1(this, n1, data, offset, async)
subroutine iaccel_get_device_pointer_1(host_pointer, device_pointer, dimensions)
subroutine laccel_read_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine, public accel_copy_buffer(dest, src, type, nval, offset_dest, offset_src, async)
Copy nval elements of the given type between two device buffers.
subroutine accel_grid_size_extend_dim_i4(n, pack_size, gridsizes, blocksizes, kernel)
Helper function to compute the grid for the kernels that relies on the batch size (pack_size) and the...
subroutine, public accel_ensure_buffer_size(buffer, flags, type, required_size, set_zero, async)
subroutine accel_set_buffer_to(buffer, type, val, nval, offset, async)
subroutine, public accel_move_buffer(buffer_from, buffer_to)
Move the buffer memory from the first buffer to the second.
subroutine, public accel_detach_buffer(this)
Clear a buffer handle without freeing device memory.
subroutine laccel_set_kernel_arg_data(kernel, narg, data)
subroutine iaccel_write_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine daccel_write_buffer_1(this, n1, data, offset, async)
subroutine daccel_read_buffer_0_int32(this, n1, data, offset, async)
subroutine zaccel_read_buffer_1(this, n1, data, offset, async)
subroutine iaccel_write_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine daccel_read_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine laccel_write_buffer_single(this, data, async)
subroutine laccel_read_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine daccel_get_device_pointer_2(host_pointer, device_pointer, dimensions)
subroutine accel_kernel_run_8(kernel, gridsizes, blocksizes, shared_memory_size)
Run a kernel with 8-byte integer sizes.
subroutine iaccel_read_buffer_2_int32(this, n1, n2, data, offset, async)
subroutine zaccel_write_buffer_0_int32(this, n1, data, offset, async)
subroutine zaccel_write_buffer_1_int32(this, n1, data, offset, async)
subroutine accel_set_buffer_to_zero_i8(buffer, type, nval, offset, async)
subroutine zaccel_get_device_pointer_1l(host_pointer, device_pointer, dimensions)
logical pure function, public accel_buffer_is_allocated(this)
integer, parameter, public accel_mem_read_write
subroutine accel_kernel_end(this)
subroutine laccel_write_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine zaccel_write_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine zaccel_get_device_pointer_2(host_pointer, device_pointer, dimensions)
subroutine daccel_write_buffer_3(this, n1, n2, n3, data, offset, async)
subroutine laccel_read_buffer_2_int32(this, n1, n2, data, offset, async)
type(c_ptr) function, public daccel_get_pointer_with_offset(buffer, offset)
subroutine iaccel_write_buffer_single(this, data, async)
subroutine iaccel_get_device_pointer_2(host_pointer, device_pointer, dimensions)
integer pure function, public accel_max_size_per_dim(dim)
subroutine zaccel_read_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine iaccel_read_buffer_0(this, n1, data, offset, async)
subroutine daccel_read_buffer_0(this, n1, data, offset, async)
subroutine iaccel_read_buffer_1_int32(this, n1, data, offset, async)
subroutine accel_grid_size_array_i4(n, blocksizes, gridsizes)
Computes the grid size for a given problem size and block size (32-bit version).
subroutine iaccel_read_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine laccel_write_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine laccel_write_buffer_0_int32(this, n1, data, offset, async)
subroutine zaccel_write_buffer_2(this, n1, n2, data, offset, async)
subroutine laccel_read_buffer_0_int32(this, n1, data, offset, async)
subroutine laccel_get_device_pointer_2l(host_pointer, device_pointer, dimensions)
subroutine iaccel_get_device_pointer_3(host_pointer, device_pointer, dimensions)
subroutine zaccel_write_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine zaccel_write_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine daccel_set_kernel_arg_data(kernel, narg, data)
subroutine iaccel_read_buffer_1(this, n1, data, offset, async)
subroutine accel_grid_size_extend_dim_i8(n, pack_size, gridsizes, blocksizes, kernel)
Helper function to compute the grid for the kernels that relies on the batch size (pack_size) and the...
subroutine, public accel_kernel_build(this, file_name, kernel_name, flags)
Compile the program that contains a given kernel.
subroutine, public accel_init(base_grp, namespace)
subroutine, public accel_end(namespace)
subroutine laccel_write_buffer_0(this, n1, data, offset, async)
subroutine daccel_write_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine zaccel_read_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine, public accel_synchronize_all_streams()
subroutine, public accel_set_stream(stream_number)
subroutine laccel_read_buffer_2(this, n1, n2, data, offset, async)
subroutine iaccel_read_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine iaccel_read_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine laccel_get_device_pointer_1l(host_pointer, device_pointer, dimensions)
subroutine iaccel_read_buffer_0_int32(this, n1, data, offset, async)
subroutine accel_grid_size_i8(n, blocksizes, gridsizes)
Computes the grid size for a given problem size and block size (64-bit version).
subroutine iaccel_write_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
integer(int32) function accel_padded_size_i4(nn)
subroutine accel_set_buffer_to_zero_i4(buffer, type, nval, offset, async)
subroutine daccel_write_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine laccel_write_buffer_1_int32(this, n1, data, offset, async)
subroutine iaccel_get_device_pointer_2l(host_pointer, device_pointer, dimensions)
subroutine iaccel_write_buffer_2_int32(this, n1, n2, data, offset, async)
pure logical function, public accel_is_enabled()
subroutine zaccel_read_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
type(alloc_cache_t) memcache
subroutine daccel_write_buffer_0_int32(this, n1, data, offset, async)
subroutine iaccel_write_buffer_4(this, n1, n2, n3, n4, data, offset, async)
subroutine daccel_write_buffer_2_int32(this, n1, n2, data, offset, async)
subroutine iaccel_write_buffer_1_int32(this, n1, data, offset, async)
integer, parameter, public accel_mem_write_only
subroutine zaccel_write_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine daccel_read_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine laccel_write_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine laccel_read_buffer_1_int32(this, n1, data, offset, async)
subroutine daccel_read_buffer_1_int32(this, n1, data, offset, async)
subroutine laccel_read_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine daccel_write_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine daccel_get_device_pointer_1l(host_pointer, device_pointer, dimensions)
subroutine iaccel_read_buffer_2(this, n1, n2, data, offset, async)
subroutine laccel_write_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine laccel_write_buffer_2(this, n1, n2, data, offset, async)
subroutine daccel_write_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine laccel_write_buffer_2_int32(this, n1, n2, data, offset, async)
subroutine zaccel_get_device_pointer_3(host_pointer, device_pointer, dimensions)
type(c_ptr) function, public zaccel_get_pointer_with_offset(buffer, offset)
subroutine iaccel_read_buffer_6_int32(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine laccel_read_buffer_3_int32(this, n1, n2, n3, data, offset, async)
subroutine daccel_write_buffer_single(this, data, async)
subroutine daccel_write_buffer_1_int32(this, n1, data, offset, async)
subroutine zaccel_write_buffer_0(this, n1, data, offset, async)
type(accel_t), public accel
subroutine laccel_get_device_pointer_3(host_pointer, device_pointer, dimensions)
subroutine iaccel_read_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
integer(int64) pure function, public accel_shared_memory_size()
integer pure function, public accel_max_block_size()
subroutine iaccel_set_kernel_arg_data(kernel, narg, data)
subroutine daccel_read_buffer_2_int32(this, n1, n2, data, offset, async)
subroutine iaccel_read_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine iaccel_write_buffer_0(this, n1, data, offset, async)
subroutine zaccel_get_device_pointer_3l(host_pointer, device_pointer, dimensions)
subroutine accel_create_buffer_8(this, flags, type, size, set_zero, async)
subroutine laccel_read_buffer_1(this, n1, data, offset, async)
subroutine daccel_read_buffer_5_int32(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine daccel_read_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine accel_program_add(file_name, name)
Register a kernel for later retrieval.
subroutine accel_set_kernel_arg_buffer(kernel, narg, buffer)
subroutine accel_kernel_list()
The kernels each source provides.
subroutine laccel_read_buffer_5(this, n1, n2, n3, n4, n5, data, offset, async)
subroutine zaccel_read_buffer_2_int32(this, n1, n2, data, offset, async)
subroutine zaccel_write_buffer_6(this, n1, n2, n3, n4, n5, n6, data, offset, async)
subroutine daccel_get_device_pointer_3(host_pointer, device_pointer, dimensions)
type(accel_kernel_t), pointer head
subroutine zaccel_read_buffer_4_int32(this, n1, n2, n3, n4, data, offset, async)
subroutine, public alloc_cache_put(alloc_cache, size, loc, put)
subroutine, public alloc_cache_get(alloc_cache, size, found, loc)
integer(int64), parameter, public alloc_cache_any_size
real(real64), parameter, public m_zero
System information (time, memory, sysname)
subroutine string_c_to_f(c_string, f_string)
convert a C string to a Fortran string
subroutine, public loct_sysname(name)
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
character(len=512), private msg
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
subroutine, public messages_new_line()
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
integer pure function, public types_get_size(this)
type(type_t), parameter, public type_none
This module defines the unit system, used for input and output.
type(unit_t), public unit_gigabytes
For larger amounts of data (natural code units are bytes)
type(unit_t), public unit_megabytes
For large amounts of data (natural code units are bytes)
type(unit_t), public unit_kilobytes
For small amounts of data (natural code units are bytes)