[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

GitOrigin-RevId: 9cd1e2228c70c9ff30bcefd5b287db8dac9c6019
diff --git a/libomptarget/include/Debug.h b/libomptarget/include/Debug.h
index 134bf8b..9585184 100644
--- a/libomptarget/include/Debug.h
+++ b/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/libomptarget/include/omptarget.h b/libomptarget/include/omptarget.h
index 9c53394..7c70704 100644
--- a/libomptarget/include/omptarget.h
+++ b/libomptarget/include/omptarget.h
@@ -14,15 +14,18 @@
 #ifndef _OMPTARGET_H_
 #define _OMPTARGET_H_
 
-#include <stdint.h>
 #include <stddef.h>
+#include <stdint.h>
 
 #include <SourceInfo.h>
 
 #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 @@
   uint64_t Stride;
 };
 
+// clang-format on
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -142,13 +147,15 @@
 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/libomptarget/src/api.cpp b/libomptarget/src/api.cpp
index 2d37610..27fec34 100644
--- a/libomptarget/src/api.cpp
+++ b/libomptarget/src/api.cpp
@@ -15,8 +15,8 @@
 #include "rtl.h"
 
 #include <climits>
-#include <cstring>
 #include <cstdlib>
+#include <cstring>
 
 EXTERN int omp_get_num_devices(void) {
   TIMESCOPE();
@@ -39,7 +39,7 @@
 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_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 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 @@
   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_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_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 @@
 
   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<num_dims; ++i) {
+    for (int i = 1; i < num_dims; ++i) {
       dst_slice_size *= dst_dimensions[i];
       src_slice_size *= src_dimensions[i];
     }
 
     size_t dst_off = dst_offsets[0] * dst_slice_size;
     size_t src_off = src_offsets[0] * src_slice_size;
-    for (size_t i=0; i<volume[0]; ++i) {
-      rc = omp_target_memcpy_rect((char *) dst + dst_off + dst_slice_size * i,
-          (char *) src + src_off + src_slice_size * i, element_size,
+    for (size_t i = 0; i < volume[0]; ++i) {
+      rc = omp_target_memcpy_rect(
+          (char *)dst + dst_off + dst_slice_size * i,
+          (char *)src + src_off + src_slice_size * i, element_size,
           num_dims - 1, volume + 1, dst_offsets + 1, src_offsets + 1,
           dst_dimensions + 1, src_dimensions + 1, dst_device, src_device);
 
@@ -255,11 +261,12 @@
 }
 
 EXTERN int omp_target_associate_ptr(void *host_ptr, void *device_ptr,
-    size_t size, size_t device_offset, int device_num) {
+                                    size_t size, size_t device_offset,
+                                    int device_num) {
   TIMESCOPE();
   DP("Call to omp_target_associate_ptr with host_ptr " DPxMOD ", "
-      "device_ptr " DPxMOD ", size %zu, device_offset %zu, device_num %d\n",
-      DPxPTR(host_ptr), DPxPTR(device_ptr), size, device_offset, device_num);
+     "device_ptr " DPxMOD ", size %zu, device_offset %zu, device_num %d\n",
+     DPxPTR(host_ptr), DPxPTR(device_ptr), size, device_offset, device_num);
 
   if (!host_ptr || !device_ptr || size <= 0) {
     REPORT("Call to omp_target_associate_ptr with invalid arguments\n");
@@ -286,7 +293,8 @@
 EXTERN int omp_target_disassociate_ptr(void *host_ptr, int device_num) {
   TIMESCOPE();
   DP("Call to omp_target_disassociate_ptr with host_ptr " DPxMOD ", "
-      "device_num %d\n", DPxPTR(host_ptr), device_num);
+     "device_num %d\n",
+     DPxPTR(host_ptr), device_num);
 
   if (!host_ptr) {
     REPORT("Call to omp_target_associate_ptr with invalid host_ptr\n");
diff --git a/libomptarget/src/device.cpp b/libomptarget/src/device.cpp
index ee90bc6..724b887 100644
--- a/libomptarget/src/device.cpp
+++ b/libomptarget/src/device.cpp
@@ -82,10 +82,10 @@
                               (uintptr_t)TgtPtrBegin /*TgtPtrBegin*/, nullptr,
                               true /*IsRefCountINF*/);
 
-  DP("Creating new map entry: HstBase=" DPxMOD ", HstBegin=" DPxMOD ", HstEnd="
-      DPxMOD ", TgtBegin=" DPxMOD "\n", DPxPTR(newEntry.HstPtrBase),
-      DPxPTR(newEntry.HstPtrBegin), DPxPTR(newEntry.HstPtrEnd),
-      DPxPTR(newEntry.TgtPtrBegin));
+  DP("Creating new map entry: HstBase=" DPxMOD ", HstBegin=" DPxMOD
+     ", HstEnd=" DPxMOD ", TgtBegin=" DPxMOD "\n",
+     DPxPTR(newEntry.HstPtrBase), DPxPTR(newEntry.HstPtrBegin),
+     DPxPTR(newEntry.HstPtrEnd), DPxPTR(newEntry.TgtPtrBegin));
   HostDataToTargetMap.insert(newEntry);
 
   DataMapMtx.unlock();
@@ -146,7 +146,7 @@
   LookupResult lr;
 
   DP("Looking up mapping(HstPtrBegin=" DPxMOD ", Size=%" PRId64 ")...\n",
-      DPxPTR(hp), Size);
+     DPxPTR(hp), Size);
 
   if (HostDataToTargetMap.empty())
     return lr;
@@ -158,7 +158,7 @@
     auto &HT = *lr.Entry;
     // Is it contained?
     lr.Flags.IsContained = hp >= 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 @@
     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 @@
   } 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 @@
 
     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 @@
       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 @@
   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/libomptarget/src/device.h b/libomptarget/src/device.h
index e79c3ba..06e24e1 100644
--- a/libomptarget/src/device.h
+++ b/libomptarget/src/device.h
@@ -44,7 +44,7 @@
 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 @@
       : 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 @@
     return RefCount;
   }
 
-  bool isRefCountInf() const {
-    return RefCount == INFRefCount;
-  }
+  bool isRefCountInf() const { return RefCount == INFRefCount; }
 };
 
 typedef uintptr_t HstPtrBeginTy;
@@ -110,14 +106,14 @@
 
 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 @@
   ~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/libomptarget/src/interface.cpp b/libomptarget/src/interface.cpp
index 01f3715..52929e1 100644
--- a/libomptarget/src/interface.cpp
+++ b/libomptarget/src/interface.cpp
@@ -123,16 +123,19 @@
 /// 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 @@
                                            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 @@
 /// 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 @@
                                          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 @@
     printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types,
                          arg_names, "Exiting OpenMP data region");
 #ifdef OMPTARGET_DEBUG
-  for (int i=0; i<arg_num; ++i) {
+  for (int i = 0; i < arg_num; ++i) {
     DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64
        ", Type=0x%" PRIx64 ", Name=%s\n",
        i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i],
@@ -281,16 +289,17 @@
 }
 
 EXTERN void __tgt_target_data_update(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_update_mapper(nullptr, device_id, arg_num, args_base, args,
                                   arg_sizes, arg_types, nullptr, nullptr);
 }
 
-EXTERN void __tgt_target_data_update_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) {
+EXTERN void __tgt_target_data_update_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) {
   TIMESCOPE();
   if (depNum + noAliasDepNum > 0)
     __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL));
@@ -306,7 +315,8 @@
                                             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 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 @@
                                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 @@
     printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types,
                          arg_names, "Entering OpenMP kernel");
 #ifdef OMPTARGET_DEBUG
-  for (int i=0; i<arg_num; ++i) {
+  for (int i = 0; i < arg_num; ++i) {
     DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64
        ", Type=0x%" PRIx64 ", Name=%s\n",
        i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i],
@@ -413,8 +427,9 @@
 }
 
 EXTERN int __tgt_target_teams(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 team_num, int32_t thread_limit) {
+                              int32_t arg_num, void **args_base, void **args,
+                              int64_t *arg_sizes, int64_t *arg_types,
+                              int32_t team_num, int32_t thread_limit) {
   TIMESCOPE();
   return __tgt_target_teams_mapper(nullptr, device_id, host_ptr, arg_num,
                                    args_base, args, arg_sizes, arg_types,
@@ -422,9 +437,12 @@
 }
 
 EXTERN int __tgt_target_teams_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 team_num, int32_t thread_limit, 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 team_num,
+                                     int32_t thread_limit, int32_t depNum,
+                                     void *depList, int32_t noAliasDepNum,
+                                     void *noAliasDepList) {
   TIMESCOPE();
   if (depNum + noAliasDepNum > 0)
     __kmpc_omp_taskwait(NULL, __kmpc_global_thread_num(NULL));
@@ -441,9 +459,11 @@
                                      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 @@
     printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types,
                          arg_names, "Entering OpenMP kernel");
 #ifdef OMPTARGET_DEBUG
-  for (int i=0; i<arg_num; ++i) {
+  for (int i = 0; i < arg_num; ++i) {
     DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64
        ", Type=0x%" PRIx64 ", Name=%s\n",
        i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i],
@@ -531,7 +551,7 @@
   }
 
   DP("__kmpc_push_target_tripcount(%" PRId64 ", %" PRIu64 ")\n", device_id,
-      loop_tripcount);
+     loop_tripcount);
   PM->TblMapMtx.lock();
   PM->Devices[device_id].LoopTripCnt.emplace(__kmpc_global_thread_num(NULL),
                                              loop_tripcount);
diff --git a/libomptarget/src/omptarget.cpp b/libomptarget/src/omptarget.cpp
index e4b7b18..8eba837 100644
--- a/libomptarget/src/omptarget.cpp
+++ b/libomptarget/src/omptarget.cpp
@@ -271,9 +271,9 @@
       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/libomptarget/src/rtl.cpp b/libomptarget/src/rtl.cpp
index 45ac5bb..6807b8b 100644
--- a/libomptarget/src/rtl.cpp
+++ b/libomptarget/src/rtl.cpp
@@ -10,9 +10,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "rtl.h"
 #include "device.h"
 #include "private.h"
-#include "rtl.h"
 
 #include <cassert>
 #include <cstdlib>
@@ -184,7 +184,8 @@
 // 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 @@
 // 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 @@
   //  - 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 @@
     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 @@
         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 @@
         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 @@
       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 @@
 
       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 @@
       }
 
       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 @@
   // 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();