From: Johannes Doerfert Date: Wed, 10 Feb 2021 17:45:39 +0000 (-0600) Subject: [OpenMP][NFC] Clang format libomptarget code (src & include) X-Git-Tag: llvmorg-14-init~14958 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9cd1e2228c70c9ff30bcefd5b287db8dac9c6019;p=platform%2Fupstream%2Fllvm.git [OpenMP][NFC] Clang format libomptarget code (src & include) The struct and enum alignments are kept by disabling clang-format for that code region. Reviewed By: tianshilei1992, JonChesterfield, grokos Differential Revision: https://reviews.llvm.org/D96428 --- diff --git a/openmp/libomptarget/include/Debug.h b/openmp/libomptarget/include/Debug.h index 134bf8b..9585184 100644 --- a/openmp/libomptarget/include/Debug.h +++ b/openmp/libomptarget/include/Debug.h @@ -14,17 +14,17 @@ // // Debug and information messages are controlled by the environment variables // LIBOMPTARGET_DEBUG and LIBOMPTARGET_INFO which is set upon initialization -// of libomptarget or the plugin RTL. +// of libomptarget or the plugin RTL. // // To printf a pointer in hex with a fixed width of 16 digits and a leading 0x, // use printf("ptr=" DPxMOD "...\n", DPxPTR(ptr)); -// +// // DPxMOD expands to: // "0x%0*" PRIxPTR // where PRIxPTR expands to an appropriate modifier for the type uintptr_t on a // specific platform, e.g. "lu" if uintptr_t is typedef'd as unsigned long: // "0x%0*lu" -// +// // Ultimately, the whole statement expands to: // printf("ptr=0x%0*lu...\n", // the 0* modifier expects an extra argument // // specifying the width of the output diff --git a/openmp/libomptarget/include/omptarget.h b/openmp/libomptarget/include/omptarget.h index 9c533944..7c70704 100644 --- a/openmp/libomptarget/include/omptarget.h +++ b/openmp/libomptarget/include/omptarget.h @@ -14,15 +14,18 @@ #ifndef _OMPTARGET_H_ #define _OMPTARGET_H_ -#include #include +#include #include #define OFFLOAD_SUCCESS (0) #define OFFLOAD_FAIL (~0) -#define OFFLOAD_DEVICE_DEFAULT -1 +#define OFFLOAD_DEVICE_DEFAULT -1 + +// Don't format out enums and structs. +// clang-format off /// Data attributes for each data reference used in an OpenMP target region. enum tgt_map_type { @@ -132,6 +135,8 @@ struct __tgt_target_non_contig { uint64_t Stride; }; +// clang-format on + #ifdef __cplusplus extern "C" { #endif @@ -142,13 +147,15 @@ void *omp_target_alloc(size_t size, int device_num); void omp_target_free(void *device_ptr, int device_num); int omp_target_is_present(void *ptr, int device_num); int omp_target_memcpy(void *dst, void *src, size_t length, size_t dst_offset, - size_t src_offset, int dst_device, int src_device); + size_t src_offset, int dst_device, int src_device); int omp_target_memcpy_rect(void *dst, void *src, size_t element_size, - int num_dims, const size_t *volume, const size_t *dst_offsets, - const size_t *src_offsets, const size_t *dst_dimensions, - const size_t *src_dimensions, int dst_device, int src_device); + int num_dims, const size_t *volume, + const size_t *dst_offsets, const size_t *src_offsets, + const size_t *dst_dimensions, + const size_t *src_dimensions, int dst_device, + int src_device); int omp_target_associate_ptr(void *host_ptr, void *device_ptr, size_t size, - size_t device_offset, int device_num); + size_t device_offset, int device_num); int omp_target_disassociate_ptr(void *host_ptr, int device_num); /// add the clauses of the requires directives in a given file diff --git a/openmp/libomptarget/src/api.cpp b/openmp/libomptarget/src/api.cpp index 2d37610..27fec34 100644 --- a/openmp/libomptarget/src/api.cpp +++ b/openmp/libomptarget/src/api.cpp @@ -15,8 +15,8 @@ #include "rtl.h" #include -#include #include +#include EXTERN int omp_get_num_devices(void) { TIMESCOPE(); @@ -39,7 +39,7 @@ EXTERN int omp_get_initial_device(void) { EXTERN void *omp_target_alloc(size_t size, int device_num) { TIMESCOPE(); DP("Call to omp_target_alloc for device %d requesting %zu bytes\n", - device_num, size); + device_num, size); if (size <= 0) { DP("Call to omp_target_alloc with non-positive length\n"); @@ -67,7 +67,7 @@ EXTERN void *omp_target_alloc(size_t size, int device_num) { EXTERN void omp_target_free(void *device_ptr, int device_num) { TIMESCOPE(); DP("Call to omp_target_free for device %d and address " DPxMOD "\n", - device_num, DPxPTR(device_ptr)); + device_num, DPxPTR(device_ptr)); if (!device_ptr) { DP("Call to omp_target_free with NULL ptr\n"); @@ -92,7 +92,7 @@ EXTERN void omp_target_free(void *device_ptr, int device_num) { EXTERN int omp_target_is_present(void *ptr, int device_num) { TIMESCOPE(); DP("Call to omp_target_is_present for device %d and address " DPxMOD "\n", - device_num, DPxPTR(ptr)); + device_num, DPxPTR(ptr)); if (!ptr) { DP("Call to omp_target_is_present with NULL ptr, returning false\n"); @@ -109,7 +109,7 @@ EXTERN int omp_target_is_present(void *ptr, int device_num) { PM->RTLsMtx.unlock(); if (DevicesSize <= (size_t)device_num) { DP("Call to omp_target_is_present with invalid device ID, returning " - "false\n"); + "false\n"); return false; } @@ -129,12 +129,14 @@ EXTERN int omp_target_is_present(void *ptr, int device_num) { } EXTERN int omp_target_memcpy(void *dst, void *src, size_t length, - size_t dst_offset, size_t src_offset, int dst_device, int src_device) { + size_t dst_offset, size_t src_offset, + int dst_device, int src_device) { TIMESCOPE(); DP("Call to omp_target_memcpy, dst device %d, src device %d, " - "dst addr " DPxMOD ", src addr " DPxMOD ", dst offset %zu, " - "src offset %zu, length %zu\n", dst_device, src_device, DPxPTR(dst), - DPxPTR(src), dst_offset, src_offset, length); + "dst addr " DPxMOD ", src addr " DPxMOD ", dst offset %zu, " + "src offset %zu, length %zu\n", + dst_device, src_device, DPxPTR(dst), DPxPTR(src), dst_offset, src_offset, + length); if (!dst || !src || length <= 0) { if (length == 0) { @@ -198,21 +200,24 @@ EXTERN int omp_target_memcpy(void *dst, void *src, size_t length, } EXTERN int omp_target_memcpy_rect(void *dst, void *src, size_t element_size, - int num_dims, const size_t *volume, const size_t *dst_offsets, - const size_t *src_offsets, const size_t *dst_dimensions, - const size_t *src_dimensions, int dst_device, int src_device) { + int num_dims, const size_t *volume, + const size_t *dst_offsets, + const size_t *src_offsets, + const size_t *dst_dimensions, + const size_t *src_dimensions, int dst_device, + int src_device) { TIMESCOPE(); DP("Call to omp_target_memcpy_rect, dst device %d, src device %d, " - "dst addr " DPxMOD ", src addr " DPxMOD ", dst offsets " DPxMOD ", " - "src offsets " DPxMOD ", dst dims " DPxMOD ", src dims " DPxMOD ", " - "volume " DPxMOD ", element size %zu, num_dims %d\n", dst_device, - src_device, DPxPTR(dst), DPxPTR(src), DPxPTR(dst_offsets), - DPxPTR(src_offsets), DPxPTR(dst_dimensions), DPxPTR(src_dimensions), - DPxPTR(volume), element_size, num_dims); + "dst addr " DPxMOD ", src addr " DPxMOD ", dst offsets " DPxMOD ", " + "src offsets " DPxMOD ", dst dims " DPxMOD ", src dims " DPxMOD ", " + "volume " DPxMOD ", element size %zu, num_dims %d\n", + dst_device, src_device, DPxPTR(dst), DPxPTR(src), DPxPTR(dst_offsets), + DPxPTR(src_offsets), DPxPTR(dst_dimensions), DPxPTR(src_dimensions), + DPxPTR(volume), element_size, num_dims); if (!(dst || src)) { DP("Call to omp_target_memcpy_rect returns max supported dimensions %d\n", - INT_MAX); + INT_MAX); return INT_MAX; } @@ -224,22 +229,23 @@ EXTERN int omp_target_memcpy_rect(void *dst, void *src, size_t element_size, int rc; if (num_dims == 1) { - rc = omp_target_memcpy(dst, src, element_size * volume[0], - element_size * dst_offsets[0], element_size * src_offsets[0], - dst_device, src_device); + rc = omp_target_memcpy( + dst, src, element_size * volume[0], element_size * dst_offsets[0], + element_size * src_offsets[0], dst_device, src_device); } else { size_t dst_slice_size = element_size; size_t src_slice_size = element_size; - for (int i=1; i= HT.HstPtrBegin && hp < HT.HstPtrEnd && - (hp+Size) <= HT.HstPtrEnd; + (hp + Size) <= HT.HstPtrEnd; // Does it extend beyond the mapped region? lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp + Size) > HT.HstPtrEnd; } @@ -169,18 +169,19 @@ LookupResult DeviceTy::lookupMapping(void *HstPtrBegin, int64_t Size) { lr.Entry = upper; auto &HT = *lr.Entry; // Does it extend into an already mapped region? - lr.Flags.ExtendsBefore = hp < HT.HstPtrBegin && (hp+Size) > HT.HstPtrBegin; + lr.Flags.ExtendsBefore = + hp < HT.HstPtrBegin && (hp + Size) > HT.HstPtrBegin; // Does it extend beyond the mapped region? - lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp+Size) > HT.HstPtrEnd; + lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp + Size) > HT.HstPtrEnd; } if (lr.Flags.ExtendsBefore) { DP("WARNING: Pointer is not mapped but section extends into already " - "mapped data\n"); + "mapped data\n"); } if (lr.Flags.ExtendsAfter) { DP("WARNING: Pointer is already mapped but section extends beyond mapped " - "region\n"); + "region\n"); } return lr; @@ -228,8 +229,9 @@ void *DeviceTy::getOrAllocTgtPtr(void *HstPtrBegin, void *HstPtrBase, } else if ((lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) && !IsImplicit) { // Explicit extension of mapped data - not allowed. MESSAGE("explicit extension not allowed: host address specified is " DPxMOD - " (%" PRId64 " bytes), but device allocation maps to host at " - DPxMOD " (%" PRId64 " bytes)", + " (%" PRId64 + " bytes), but device allocation maps to host at " DPxMOD + " (%" PRId64 " bytes)", DPxPTR(HstPtrBegin), Size, DPxPTR(lr.Entry->HstPtrBegin), lr.Entry->HstPtrEnd - lr.Entry->HstPtrBegin); if (HasPresentModifier) @@ -298,16 +300,18 @@ void *DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size, bool &IsLast, uintptr_t tp = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin); DP("Mapping exists with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", " - "Size=%" PRId64 ",%s RefCount=%s\n", DPxPTR(HstPtrBegin), DPxPTR(tp), - Size, (UpdateRefCount ? " updated" : ""), - HT.isRefCountInf() ? "INF" : std::to_string(HT.getRefCount()).c_str()); + "Size=%" PRId64 ",%s RefCount=%s\n", + DPxPTR(HstPtrBegin), DPxPTR(tp), Size, + (UpdateRefCount ? " updated" : ""), + HT.isRefCountInf() ? "INF" : std::to_string(HT.getRefCount()).c_str()); rc = (void *)tp; } else if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) { // If the value isn't found in the mapping and unified shared memory // is on then it means we have stumbled upon a value which we need to // use directly from the host. DP("Get HstPtrBegin " DPxMOD " Size=%" PRId64 " RefCount=%s\n", - DPxPTR((uintptr_t)HstPtrBegin), Size, (UpdateRefCount ? " updated" : "")); + DPxPTR((uintptr_t)HstPtrBegin), Size, + (UpdateRefCount ? " updated" : "")); IsHostPtr = true; rc = HstPtrBegin; } @@ -345,11 +349,12 @@ int DeviceTy::deallocTgtPtr(void *HstPtrBegin, int64_t Size, bool ForceDelete, HT.resetRefCount(); if (HT.decRefCount() == 0) { DP("Deleting tgt data " DPxMOD " of size %" PRId64 "\n", - DPxPTR(HT.TgtPtrBegin), Size); + DPxPTR(HT.TgtPtrBegin), Size); deleteData((void *)HT.TgtPtrBegin); DP("Removing%s mapping with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD - ", Size=%" PRId64 "\n", (ForceDelete ? " (forced)" : ""), - DPxPTR(HT.HstPtrBegin), DPxPTR(HT.TgtPtrBegin), Size); + ", Size=%" PRId64 "\n", + (ForceDelete ? " (forced)" : ""), DPxPTR(HT.HstPtrBegin), + DPxPTR(HT.TgtPtrBegin), Size); HostDataToTargetMap.erase(lr.Entry); } rc = OFFLOAD_SUCCESS; @@ -504,7 +509,7 @@ bool device_is_ready(int device_num) { DeviceTy &Device = PM->Devices[device_num]; DP("Is the device %d (local ID %d) initialized? %d\n", device_num, - Device.RTLDeviceID, Device.IsInit); + Device.RTLDeviceID, Device.IsInit); // Init the device if not done before if (!Device.IsInit && Device.initOnce() != OFFLOAD_SUCCESS) { diff --git a/openmp/libomptarget/src/device.h b/openmp/libomptarget/src/device.h index e79c3ba..06e24e1 100644 --- a/openmp/libomptarget/src/device.h +++ b/openmp/libomptarget/src/device.h @@ -44,7 +44,7 @@ typedef enum kmp_target_offload_kind kmp_target_offload_kind_t; struct HostDataToTargetTy { uintptr_t HstPtrBase; // host info. uintptr_t HstPtrBegin; - uintptr_t HstPtrEnd; // non-inclusive. + uintptr_t HstPtrEnd; // non-inclusive. map_var_info_t HstPtrName; // Optional source name of mapped variable. uintptr_t TgtPtrBegin; // target info. @@ -60,9 +60,7 @@ public: : HstPtrBase(BP), HstPtrBegin(B), HstPtrEnd(E), HstPtrName(Name), TgtPtrBegin(TB), RefCount(IsINF ? INFRefCount : 1) {} - uint64_t getRefCount() const { - return RefCount; - } + uint64_t getRefCount() const { return RefCount; } uint64_t resetRefCount() const { if (RefCount != INFRefCount) @@ -89,9 +87,7 @@ public: return RefCount; } - bool isRefCountInf() const { - return RefCount == INFRefCount; - } + bool isRefCountInf() const { return RefCount == INFRefCount; } }; typedef uintptr_t HstPtrBeginTy; @@ -110,14 +106,14 @@ typedef std::set> HostDataToTargetListTy; struct LookupResult { struct { - unsigned IsContained : 1; + unsigned IsContained : 1; unsigned ExtendsBefore : 1; - unsigned ExtendsAfter : 1; + unsigned ExtendsAfter : 1; } Flags; HostDataToTargetListTy::iterator Entry; - LookupResult() : Flags({0,0,0}), Entry() {} + LookupResult() : Flags({0, 0, 0}), Entry() {} }; /// Map for shadow pointers @@ -167,7 +163,7 @@ struct DeviceTy { ~DeviceTy(); // Return true if data can be copied to DstDevice directly - bool isDataExchangable(const DeviceTy& DstDevice); + bool isDataExchangable(const DeviceTy &DstDevice); uint64_t getMapEntryRefCnt(void *HstPtrBegin); LookupResult lookupMapping(void *HstPtrBegin, int64_t Size); diff --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp index 01f3715..52929e1 100644 --- a/openmp/libomptarget/src/interface.cpp +++ b/openmp/libomptarget/src/interface.cpp @@ -123,16 +123,19 @@ EXTERN void __tgt_unregister_lib(__tgt_bin_desc *desc) { /// libomptarget.so internal structure (an entry in a stack of data maps) /// and passes the data to the device. EXTERN void __tgt_target_data_begin(int64_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { + void **args_base, void **args, + int64_t *arg_sizes, int64_t *arg_types) { TIMESCOPE(); __tgt_target_data_begin_mapper(nullptr, device_id, arg_num, args_base, args, arg_sizes, arg_types, nullptr, nullptr); } EXTERN void __tgt_target_data_begin_nowait(int64_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, - int32_t depNum, void *depList, int32_t noAliasDepNum, - void *noAliasDepList) { + void **args_base, void **args, + int64_t *arg_sizes, + int64_t *arg_types, int32_t depNum, + void *depList, int32_t noAliasDepNum, + void *noAliasDepList) { TIMESCOPE(); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL)); @@ -148,10 +151,11 @@ EXTERN void __tgt_target_data_begin_mapper(ident_t *loc, int64_t device_id, map_var_info_t *arg_names, void **arg_mappers) { TIMESCOPE_WITH_IDENT(loc); - if (IsOffloadDisabled()) return; + if (IsOffloadDisabled()) + return; DP("Entering data begin region for device %" PRId64 " with %d mappings\n", - device_id, arg_num); + device_id, arg_num); // No devices available? if (device_id == OFFLOAD_DEVICE_DEFAULT) { @@ -201,16 +205,19 @@ EXTERN void __tgt_target_data_begin_nowait_mapper( /// the host-target mapping (top entry from the stack of data maps) /// created by the last __tgt_target_data_begin. EXTERN void __tgt_target_data_end(int64_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { + void **args_base, void **args, + int64_t *arg_sizes, int64_t *arg_types) { TIMESCOPE(); __tgt_target_data_end_mapper(nullptr, device_id, arg_num, args_base, args, arg_sizes, arg_types, nullptr, nullptr); } EXTERN void __tgt_target_data_end_nowait(int64_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, - int32_t depNum, void *depList, int32_t noAliasDepNum, - void *noAliasDepList) { + void **args_base, void **args, + int64_t *arg_sizes, int64_t *arg_types, + int32_t depNum, void *depList, + int32_t noAliasDepNum, + void *noAliasDepList) { TIMESCOPE(); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL)); @@ -226,7 +233,8 @@ EXTERN void __tgt_target_data_end_mapper(ident_t *loc, int64_t device_id, map_var_info_t *arg_names, void **arg_mappers) { TIMESCOPE_WITH_IDENT(loc); - if (IsOffloadDisabled()) return; + if (IsOffloadDisabled()) + return; DP("Entering data end region with %d mappings\n", arg_num); // No devices available? @@ -254,7 +262,7 @@ EXTERN void __tgt_target_data_end_mapper(ident_t *loc, int64_t device_id, printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, arg_names, "Exiting OpenMP data region"); #ifdef OMPTARGET_DEBUG - for (int i=0; i 0) __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL)); @@ -306,7 +315,8 @@ EXTERN void __tgt_target_data_update_mapper(ident_t *loc, int64_t device_id, map_var_info_t *arg_names, void **arg_mappers) { TIMESCOPE_WITH_IDENT(loc); - if (IsOffloadDisabled()) return; + if (IsOffloadDisabled()) + return; DP("Entering data update with %d mappings\n", arg_num); // No devices available? @@ -344,16 +354,18 @@ EXTERN void __tgt_target_data_update_nowait_mapper( } EXTERN int __tgt_target(int64_t device_id, void *host_ptr, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { + void **args_base, void **args, int64_t *arg_sizes, + int64_t *arg_types) { TIMESCOPE(); return __tgt_target_mapper(nullptr, device_id, host_ptr, arg_num, args_base, args, arg_sizes, arg_types, nullptr, nullptr); } EXTERN int __tgt_target_nowait(int64_t device_id, void *host_ptr, - int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, - void *noAliasDepList) { + int32_t arg_num, void **args_base, void **args, + int64_t *arg_sizes, int64_t *arg_types, + int32_t depNum, void *depList, + int32_t noAliasDepNum, void *noAliasDepList) { TIMESCOPE(); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL)); @@ -367,9 +379,11 @@ EXTERN int __tgt_target_mapper(ident_t *loc, int64_t device_id, void *host_ptr, int64_t *arg_sizes, int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers) { TIMESCOPE_WITH_IDENT(loc); - if (IsOffloadDisabled()) return OFFLOAD_FAIL; - DP("Entering target region with entry point " DPxMOD " and device Id %" - PRId64 "\n", DPxPTR(host_ptr), device_id); + if (IsOffloadDisabled()) + return OFFLOAD_FAIL; + DP("Entering target region with entry point " DPxMOD " and device Id %" PRId64 + "\n", + DPxPTR(host_ptr), device_id); if (device_id == OFFLOAD_DEVICE_DEFAULT) { device_id = omp_get_default_device(); @@ -385,7 +399,7 @@ EXTERN int __tgt_target_mapper(ident_t *loc, int64_t device_id, void *host_ptr, printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, arg_names, "Entering OpenMP kernel"); #ifdef OMPTARGET_DEBUG - for (int i=0; i 0) __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL)); @@ -441,9 +459,11 @@ EXTERN int __tgt_target_teams_mapper(ident_t *loc, int64_t device_id, map_var_info_t *arg_names, void **arg_mappers, int32_t team_num, int32_t thread_limit) { - if (IsOffloadDisabled()) return OFFLOAD_FAIL; - DP("Entering target region with entry point " DPxMOD " and device Id %" - PRId64 "\n", DPxPTR(host_ptr), device_id); + if (IsOffloadDisabled()) + return OFFLOAD_FAIL; + DP("Entering target region with entry point " DPxMOD " and device Id %" PRId64 + "\n", + DPxPTR(host_ptr), device_id); if (device_id == OFFLOAD_DEVICE_DEFAULT) { device_id = omp_get_default_device(); @@ -459,7 +479,7 @@ EXTERN int __tgt_target_teams_mapper(ident_t *loc, int64_t device_id, printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, arg_names, "Entering OpenMP kernel"); #ifdef OMPTARGET_DEBUG - for (int i=0; iTblMapMtx.lock(); PM->Devices[device_id].LoopTripCnt.emplace(__kmpc_global_thread_num(NULL), loop_tripcount); diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp index e4b7b18b..8eba837 100644 --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -271,9 +271,9 @@ int targetDataBegin(ident_t *loc, DeviceTy &Device, int32_t arg_num, DP("Calling targetDataMapper for the %dth argument\n", i); map_var_info_t arg_name = (!arg_names) ? nullptr : arg_names[i]; - int rc = targetDataMapper(loc, Device, args_base[i], args[i], arg_sizes[i], - arg_types[i], arg_name, arg_mappers[i], - targetDataBegin); + int rc = targetDataMapper(loc, Device, args_base[i], args[i], + arg_sizes[i], arg_types[i], arg_name, + arg_mappers[i], targetDataBegin); if (rc != OFFLOAD_SUCCESS) { REPORT("Call to targetDataBegin via targetDataMapper for custom mapper" diff --git a/openmp/libomptarget/src/rtl.cpp b/openmp/libomptarget/src/rtl.cpp index 45ac5bb..6807b8b 100644 --- a/openmp/libomptarget/src/rtl.cpp +++ b/openmp/libomptarget/src/rtl.cpp @@ -10,9 +10,9 @@ // //===----------------------------------------------------------------------===// +#include "rtl.h" #include "device.h" #include "private.h" -#include "rtl.h" #include #include @@ -184,7 +184,8 @@ void RTLsTy::LoadRTLs() { // Functionality for registering libs static void RegisterImageIntoTranslationTable(TranslationTable &TT, - RTLInfoTy &RTL, __tgt_device_image *image) { + RTLInfoTy &RTL, + __tgt_device_image *image) { // same size, as when we increase one, we also increase the other. assert(TT.TargetsTable.size() == TT.TargetsImages.size() && @@ -213,23 +214,24 @@ static void RegisterImageIntoTranslationTable(TranslationTable &TT, // Functionality for registering Ctors/Dtors static void RegisterGlobalCtorsDtorsForImage(__tgt_bin_desc *desc, - __tgt_device_image *img, RTLInfoTy *RTL) { + __tgt_device_image *img, + RTLInfoTy *RTL) { for (int32_t i = 0; i < RTL->NumberOfDevices; ++i) { DeviceTy &Device = PM->Devices[RTL->Idx + i]; Device.PendingGlobalsMtx.lock(); Device.HasPendingGlobals = true; for (__tgt_offload_entry *entry = img->EntriesBegin; - entry != img->EntriesEnd; ++entry) { + entry != img->EntriesEnd; ++entry) { if (entry->flags & OMP_DECLARE_TARGET_CTOR) { DP("Adding ctor " DPxMOD " to the pending list.\n", - DPxPTR(entry->addr)); + DPxPTR(entry->addr)); Device.PendingCtorsDtors[desc].PendingCtors.push_back(entry->addr); } else if (entry->flags & OMP_DECLARE_TARGET_DTOR) { // Dtors are pushed in reverse order so they are executed from end // to beginning when unregistering the library! DP("Adding dtor " DPxMOD " to the pending list.\n", - DPxPTR(entry->addr)); + DPxPTR(entry->addr)); Device.PendingCtorsDtors[desc].PendingDtors.push_front(entry->addr); } @@ -261,17 +263,18 @@ void RTLsTy::RegisterRequires(int64_t flags) { // - unified_shared_memory if ((RequiresFlags & OMP_REQ_REVERSE_OFFLOAD) != (flags & OMP_REQ_REVERSE_OFFLOAD)) { - FATAL_MESSAGE0(1, - "'#pragma omp requires reverse_offload' not used consistently!"); + FATAL_MESSAGE0( + 1, "'#pragma omp requires reverse_offload' not used consistently!"); } if ((RequiresFlags & OMP_REQ_UNIFIED_ADDRESS) != - (flags & OMP_REQ_UNIFIED_ADDRESS)) { - FATAL_MESSAGE0(1, - "'#pragma omp requires unified_address' not used consistently!"); + (flags & OMP_REQ_UNIFIED_ADDRESS)) { + FATAL_MESSAGE0( + 1, "'#pragma omp requires unified_address' not used consistently!"); } if ((RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) != - (flags & OMP_REQ_UNIFIED_SHARED_MEMORY)) { - FATAL_MESSAGE0(1, + (flags & OMP_REQ_UNIFIED_SHARED_MEMORY)) { + FATAL_MESSAGE0( + 1, "'#pragma omp requires unified_shared_memory' not used consistently!"); } @@ -295,12 +298,12 @@ void RTLsTy::RegisterLib(__tgt_bin_desc *desc) { for (auto &R : AllRTLs) { if (!R.is_valid_binary(img)) { DP("Image " DPxMOD " is NOT compatible with RTL %s!\n", - DPxPTR(img->ImageStart), R.RTLName.c_str()); + DPxPTR(img->ImageStart), R.RTLName.c_str()); continue; } DP("Image " DPxMOD " is compatible with RTL %s!\n", - DPxPTR(img->ImageStart), R.RTLName.c_str()); + DPxPTR(img->ImageStart), R.RTLName.c_str()); // If this RTL is not already in use, initialize it. if (!R.isUsed) { @@ -309,7 +312,7 @@ void RTLsTy::RegisterLib(__tgt_bin_desc *desc) { size_t Start = PM->Devices.size(); PM->Devices.resize(Start + R.NumberOfDevices, device); for (int32_t device_id = 0; device_id < R.NumberOfDevices; - device_id++) { + device_id++) { // global device ID PM->Devices[Start + device_id].DeviceID = Start + device_id; // RTL local device ID @@ -320,8 +323,8 @@ void RTLsTy::RegisterLib(__tgt_bin_desc *desc) { R.Idx = (UsedRTLs.empty()) ? 0 : UsedRTLs.back()->Idx + UsedRTLs.back()->NumberOfDevices; - assert((size_t) R.Idx == Start && - "RTL index should equal the number of devices used so far."); + assert((size_t)R.Idx == Start && + "RTL index should equal the number of devices used so far."); R.isUsed = true; UsedRTLs.push_back(&R); @@ -341,8 +344,8 @@ void RTLsTy::RegisterLib(__tgt_bin_desc *desc) { TranslationTable &TransTable = (PM->HostEntriesBeginToTransTable)[desc->HostEntriesBegin]; - DP("Registering image " DPxMOD " with RTL %s!\n", - DPxPTR(img->ImageStart), R.RTLName.c_str()); + DP("Registering image " DPxMOD " with RTL %s!\n", DPxPTR(img->ImageStart), + R.RTLName.c_str()); RegisterImageIntoTranslationTable(TransTable, R, img); PM->TrlTblMtx.unlock(); FoundRTL = &R; @@ -382,12 +385,12 @@ void RTLsTy::UnregisterLib(__tgt_bin_desc *desc) { if (!R->is_valid_binary(img)) { DP("Image " DPxMOD " is NOT compatible with RTL " DPxMOD "!\n", - DPxPTR(img->ImageStart), DPxPTR(R->LibraryHandler)); + DPxPTR(img->ImageStart), DPxPTR(R->LibraryHandler)); continue; } DP("Image " DPxMOD " is compatible with RTL " DPxMOD "!\n", - DPxPTR(img->ImageStart), DPxPTR(R->LibraryHandler)); + DPxPTR(img->ImageStart), DPxPTR(R->LibraryHandler)); FoundRTL = R; @@ -412,15 +415,15 @@ void RTLsTy::UnregisterLib(__tgt_bin_desc *desc) { } DP("Unregistered image " DPxMOD " from RTL " DPxMOD "!\n", - DPxPTR(img->ImageStart), DPxPTR(R->LibraryHandler)); + DPxPTR(img->ImageStart), DPxPTR(R->LibraryHandler)); break; } // if no RTL was found proceed to unregister the next image - if (!FoundRTL){ + if (!FoundRTL) { DP("No RTLs in use support the image " DPxMOD "!\n", - DPxPTR(img->ImageStart)); + DPxPTR(img->ImageStart)); } } PM->RTLsMtx.unlock(); @@ -429,19 +432,21 @@ void RTLsTy::UnregisterLib(__tgt_bin_desc *desc) { // Remove entries from PM->HostPtrToTableMap PM->TblMapMtx.lock(); for (__tgt_offload_entry *cur = desc->HostEntriesBegin; - cur < desc->HostEntriesEnd; ++cur) { + cur < desc->HostEntriesEnd; ++cur) { PM->HostPtrToTableMap.erase(cur->addr); } // Remove translation table for this descriptor. - auto TransTable = PM->HostEntriesBeginToTransTable.find(desc->HostEntriesBegin); + auto TransTable = + PM->HostEntriesBeginToTransTable.find(desc->HostEntriesBegin); if (TransTable != PM->HostEntriesBeginToTransTable.end()) { DP("Removing translation table for descriptor " DPxMOD "\n", - DPxPTR(desc->HostEntriesBegin)); + DPxPTR(desc->HostEntriesBegin)); PM->HostEntriesBeginToTransTable.erase(TransTable); } else { DP("Translation table for descriptor " DPxMOD " cannot be found, probably " - "it has been already removed.\n", DPxPTR(desc->HostEntriesBegin)); + "it has been already removed.\n", + DPxPTR(desc->HostEntriesBegin)); } PM->TblMapMtx.unlock();