EPCCed / gpu-directives

Contains material for a course using GPU directives
0 stars 0 forks source link

Create mappers for data structures #1

Open lucaparisi91 opened 2 months ago

lucaparisi91 commented 2 months ago

Examples are found in https://www.openmp.org/wp-content/uploads/openmp-examples-5.0.0.pdf . You can use

#pragma omp declare mapper( my_wrapper : sutrct_t my_obj )   [map instructions]

You can also map only part of a data structure. A working example is in custom_mappers directory

compiler supported
clang 18.1.8 OK
nvhpc 24.5 NO
gcc 13 NO
lucaparisi91 commented 1 month ago

Some additional notes

linear modifier : ? in_reduction : ? -> mapped to (always,tofrom)

Can use function call omp_target_allocate / omp_target_free . is_device_ptr -> the pointer points to GPU memory ( Fortran: type C_PTR ) not necessary when using requires unified_adress

Can be used to interoperate with CUDA/ROCm . has_device_addr : tell the address is associated with a device , can be used with a C pointer. defaultmap : change the defaults Array sections in OpenMP: [[ lower-bound]: length [:stride] ] . Should avoid overlap between different sections map directives are not persistent across device environments. target data : data is persistent in the whole environment. For it to be globally persistent use target enter data,target exit data. omp target update from/to. #ragma omp declare target : variable , function can be executed on the device. mapped variables have an implicit declare target attribute -> enter , link , device_type ( host or any ) , indirect ( for function pointers ) omp_target_is_present omp_target_is_accessible -> must be called on the host omp_get_mapped_ptr -> get the pointer to allocated data on the device.

omp_target_memcpy_rect, omp_target_memcpy_async,omp_target_memcopy_rect_async, omp_target_memcpy: copy a region of memory omp_target_associate_ptr omp_target_dissasociate_ptr default_map(implicit_behaviour[:variable_category]) clause is used to set the default mapping behaviour for variables, variable_category is one of [scalar,aggregate,pointer,allocatable(Fortran)]. implicit-behaviour is one of [alloc, to , from,tofrom,firstprivate,none,default]