forked from ecmwf/atlas
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/refactor_pack_vector_fields
- Loading branch information
Showing
17 changed files
with
144 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,27 @@ | ||
### OpenACC | ||
|
||
if( atlas_HAVE_ATLAS_FIELD ) | ||
if( atlas_HAVE_ATLAS_FIELD AND HAVE_GPU ) | ||
|
||
set( ATLAS_ACC_CAPABLE FALSE ) | ||
if( HAVE_GPU ) | ||
if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC" ) | ||
set( ATLAS_ACC_CAPABLE TRUE ) | ||
else() | ||
find_package(OpenACC COMPONENTS C Fortran) | ||
if(OpenACC_Fortran_FOUND AND OpenACC_C_FOUND) | ||
set( ATLAS_ACC_CAPABLE TRUE ) | ||
if( DEFINED ATLAS_ENABLE_ACC ) | ||
set( ENABLE_ACC ${ATLAS_ENABLE_ACC} ) | ||
endif() | ||
if( ENABLE_ACC ) | ||
if( NOT HAVE_FORTRAN ) | ||
enable_language(Fortran) | ||
endif() | ||
find_package( OpenACC COMPONENTS Fortran CXX ) | ||
endif() | ||
endif() | ||
|
||
ecbuild_add_option( FEATURE ACC | ||
DESCRIPTION "OpenACC capable data structures" | ||
CONDITION ATLAS_ACC_CAPABLE ) | ||
|
||
if( atlas_HAVE_ACC ) | ||
if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC" ) | ||
#set( ACC_Fortran_FLAGS -acc -ta=tesla,nordc ) | ||
set( ACC_Fortran_FLAGS "-acc=gpu;-gpu=gvmode,lineinfo,fastmath,rdc" ) | ||
set( ACC_C_FLAGS ${ACC_Fortran_FLAGS} ) | ||
find_program( ACC_C_COMPILER NAMES pgcc HINTS ${PGI_DIR} ${NVPHC_DIR} ENV PGI_DIR NVHPC_DIR PATH_SUFFIXES bin ) | ||
if( NOT ACC_C_COMPILER ) | ||
ecbuild_error( "Could not find OpenACC capable C compiler" ) | ||
endif() | ||
else() | ||
set( ACC_Fortran_FLAGS ${OpenACC_Fortran_FLAGS} ) | ||
set( ACC_C_FLAGS ${OpenACC_C_FLAGS} ) | ||
ecbuild_add_option( FEATURE ACC | ||
DESCRIPTION "OpenACC capable data structures" | ||
CONDITION OpenACC_Fortran_FOUND ) | ||
if( HAVE_ACC ) | ||
set( ACC_LINK_OPTIONS ${OpenACC_Fortran_FLAGS} ) | ||
endif() | ||
endif() | ||
|
||
else() | ||
|
||
set( HAVE_ACC 0 ) | ||
set( atlas_HAVE_ACC 0 ) | ||
endif() | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
module atlas_acc | ||
use openacc | ||
implicit none | ||
private | ||
|
||
public :: atlas_acc_get_num_devices | ||
public :: atlas_acc_map_data | ||
public :: atlas_acc_unmap_data | ||
public :: atlas_acc_is_present | ||
public :: atlas_acc_get_device_type | ||
public :: atlas_acc_deviceptr | ||
|
||
contains | ||
|
||
function atlas_acc_get_num_devices() bind(C,name="atlas_acc_get_num_devices") result(num_devices) | ||
use, intrinsic :: iso_c_binding, only : c_int | ||
integer(c_int) :: num_devices | ||
integer(acc_device_kind) :: devicetype | ||
|
||
devicetype = acc_get_device_type() | ||
num_devices = acc_get_num_devices(devicetype) | ||
end function | ||
|
||
subroutine atlas_acc_map_data(data_arg, data_dev, bytes) bind(C,name="atlas_acc_map_data") | ||
use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t | ||
type(*), dimension(*) :: data_arg | ||
type(c_ptr), value :: data_dev | ||
integer(c_size_t), value :: bytes | ||
call acc_map_data(data_arg, data_dev, bytes) | ||
end subroutine | ||
|
||
subroutine atlas_acc_unmap_data(data_arg) bind(C,name="atlas_acc_unmap_data") | ||
use, intrinsic :: iso_c_binding, only : c_ptr | ||
type(*), dimension(*) :: data_arg | ||
call acc_unmap_data(data_arg) | ||
end subroutine | ||
|
||
function atlas_acc_is_present(data_arg, bytes) bind(C,name="atlas_acc_is_present") result(is_present) | ||
use, intrinsic :: iso_c_binding, only : c_size_t, c_ptr, c_char, c_int | ||
integer(c_int) :: is_present | ||
logical :: lpresent | ||
type(c_ptr), value :: data_arg | ||
integer(c_size_t), value :: bytes | ||
character(kind=c_char), pointer :: data_f(:) | ||
call c_f_pointer(data_arg, data_f,[bytes]) | ||
lpresent = acc_is_present(data_f) | ||
is_present = 0 | ||
if (lpresent) is_present = 1 | ||
end function | ||
|
||
function atlas_acc_deviceptr(data_arg) bind(C,name="atlas_acc_deviceptr") result(deviceptr) | ||
use, intrinsic :: iso_c_binding, only : c_ptr | ||
type(*), dimension(*) :: data_arg | ||
type(c_ptr):: deviceptr | ||
deviceptr = acc_deviceptr(data_arg) | ||
end function | ||
|
||
function atlas_acc_get_device_type() bind(C,name="atlas_acc_get_device_type") result(devicetype) | ||
use, intrinsic :: iso_c_binding, only : c_int | ||
integer(c_int) :: devicetype | ||
integer(acc_device_kind) :: acc_devicetype | ||
acc_devicetype = acc_get_device_type() | ||
if (acc_devicetype == acc_device_host .or. acc_devicetype == acc_device_none) then | ||
devicetype = 0 | ||
else | ||
devicetype = 1 | ||
endif | ||
end function | ||
|
||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.