Skip to content

Commit 309b00a

Browse files
committed
[OpenMP][NFC] clang-format the whole openmp project
Same script as D95318. Test files are excluded. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D97088
1 parent 6984e0d commit 309b00a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4768
-3814
lines changed

openmp/libomptarget/deviceRTLs/amdgcn/src/amdgcn_locks.hip

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ DEVICE void __kmpc_impl_init_lock(omp_lock_t *) { warn(); }
2626
DEVICE void __kmpc_impl_destroy_lock(omp_lock_t *) { warn(); }
2727
DEVICE void __kmpc_impl_set_lock(omp_lock_t *) { warn(); }
2828
DEVICE void __kmpc_impl_unset_lock(omp_lock_t *) { warn(); }
29-
DEVICE int __kmpc_impl_test_lock(omp_lock_t *lock) { warn(); return 0;}
29+
DEVICE int __kmpc_impl_test_lock(omp_lock_t *lock) {
30+
warn();
31+
return 0;
32+
}
3033

3134
#pragma omp end declare target

openmp/libomptarget/deviceRTLs/common/omptarget.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class omptarget_nvptx_SharedArgs {
4040
public:
4141
// All these methods must be called by the master thread only.
4242
INLINE void Init() {
43-
args = buffer;
43+
args = buffer;
4444
nArgs = MAX_SHARED_ARGS;
4545
}
4646
INLINE void DeInit() {
@@ -62,6 +62,7 @@ class omptarget_nvptx_SharedArgs {
6262
}
6363
// Called by all threads.
6464
INLINE void **GetArgs() const { return args; };
65+
6566
private:
6667
// buffer of pre-allocated arguments.
6768
void *buffer[MAX_SHARED_ARGS];
@@ -91,7 +92,7 @@ struct __kmpc_data_sharing_slot {
9192
struct DataSharingStateTy {
9293
__kmpc_data_sharing_slot *SlotPtr[DS_Max_Warp_Number];
9394
void *StackPtr[DS_Max_Warp_Number];
94-
void * volatile FramePtr[DS_Max_Warp_Number];
95+
void *volatile FramePtr[DS_Max_Warp_Number];
9596
__kmpc_impl_lanemask_t ActiveThreads[DS_Max_Warp_Number];
9697
};
9798

openmp/libomptarget/deviceRTLs/common/omptargeti.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ INLINE void omptarget_nvptx_TaskDescr::SetRuntimeSched(omp_sched_t sched) {
3030
items.flags |= val;
3131
}
3232

33-
INLINE void
34-
omptarget_nvptx_TaskDescr::InitLevelZeroTaskDescr() {
33+
INLINE void omptarget_nvptx_TaskDescr::InitLevelZeroTaskDescr() {
3534
// slow method
3635
// flag:
3736
// default sched is static,
@@ -53,10 +52,9 @@ INLINE void omptarget_nvptx_TaskDescr::InitLevelOneTaskDescr(
5352
// dyn is off (unused now anyway, but may need to sample from host ?)
5453
// in L1 parallel
5554

56-
items.flags =
57-
TaskDescr_InPar | TaskDescr_IsParConstr; // set flag to parallel
55+
items.flags = TaskDescr_InPar | TaskDescr_IsParConstr; // set flag to parallel
5856
items.threadId =
59-
GetThreadIdInBlock(); // get ids from cuda (only called for 1st level)
57+
GetThreadIdInBlock(); // get ids from cuda (only called for 1st level)
6058
items.runtimeChunkSize = 1; // preferred chunking statik with chunk 1
6159
prev = parentTaskDescr;
6260
}

openmp/libomptarget/deviceRTLs/common/src/cancel.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212
#pragma omp declare target
1313

14-
#include "interface.h"
1514
#include "common/debug.h"
15+
#include "interface.h"
1616

1717
EXTERN int32_t __kmpc_cancellationpoint(kmp_Ident *loc, int32_t global_tid,
1818
int32_t cancelVal) {

openmp/libomptarget/deviceRTLs/common/src/critical.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212
#pragma omp declare target
1313

14-
#include "interface.h"
1514
#include "common/debug.h"
15+
#include "interface.h"
1616

1717
EXTERN
1818
void __kmpc_critical(kmp_Ident *loc, int32_t global_tid,

openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ EXTERN void __kmpc_data_sharing_init_stack_spmd() {
6262
__kmpc_impl_threadfence_block();
6363
}
6464

65-
INLINE static void* data_sharing_push_stack_common(size_t PushSize) {
65+
INLINE static void *data_sharing_push_stack_common(size_t PushSize) {
6666
ASSERT0(LT_FUSSY, isRuntimeInitialized(), "Expected initialized runtime.");
6767

6868
// Only warp active master threads manage the stack.
@@ -103,7 +103,7 @@ INLINE static void* data_sharing_push_stack_common(size_t PushSize) {
103103
size_t DefaultSlotSize = DS_Worker_Warp_Slot_Size;
104104
if (DefaultSlotSize > NewSize)
105105
NewSize = DefaultSlotSize;
106-
NewSlot = (__kmpc_data_sharing_slot *) SafeMalloc(
106+
NewSlot = (__kmpc_data_sharing_slot *)SafeMalloc(
107107
sizeof(__kmpc_data_sharing_slot) + NewSize,
108108
"Global memory slot allocation.");
109109

@@ -163,8 +163,8 @@ EXTERN void *__kmpc_data_sharing_push_stack(size_t DataSize,
163163

164164
// Compute the start address of the frame of each thread in the warp.
165165
uintptr_t FrameStartAddress =
166-
(uintptr_t) data_sharing_push_stack_common(PushSize);
167-
FrameStartAddress += (uintptr_t) (GetLaneId() * DataSize);
166+
(uintptr_t)data_sharing_push_stack_common(PushSize);
167+
FrameStartAddress += (uintptr_t)(GetLaneId() * DataSize);
168168
return (void *)FrameStartAddress;
169169
}
170170

openmp/libomptarget/deviceRTLs/common/src/loop.cu

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public:
410410
T loopLowerBound, T loopUpperBound) {
411411
T N = NextIter();
412412
lb = loopLowerBound + N * chunkSize;
413-
ub = lb + chunkSize - 1; // Clang uses i <= ub
413+
ub = lb + chunkSize - 1; // Clang uses i <= ub
414414

415415
// 3 result cases:
416416
// a. lb and ub < loopUpperBound --> NOT_FINISHED
@@ -567,9 +567,9 @@ EXTERN int __kmpc_dispatch_next_4(kmp_Ident *loc, int32_t tid, int32_t *p_last,
567567
loc, tid, p_last, p_lb, p_ub, p_st);
568568
}
569569

570-
EXTERN int __kmpc_dispatch_next_4u(kmp_Ident *loc, int32_t tid,
571-
int32_t *p_last, uint32_t *p_lb,
572-
uint32_t *p_ub, int32_t *p_st) {
570+
EXTERN int __kmpc_dispatch_next_4u(kmp_Ident *loc, int32_t tid, int32_t *p_last,
571+
uint32_t *p_lb, uint32_t *p_ub,
572+
int32_t *p_st) {
573573
PRINT0(LD_IO, "call kmpc_dispatch_next_4u\n");
574574
return omptarget_nvptx_LoopSupport<uint32_t, int32_t>::dispatch_next(
575575
loc, tid, p_last, p_lb, p_ub, p_st);
@@ -582,9 +582,9 @@ EXTERN int __kmpc_dispatch_next_8(kmp_Ident *loc, int32_t tid, int32_t *p_last,
582582
loc, tid, p_last, p_lb, p_ub, p_st);
583583
}
584584

585-
EXTERN int __kmpc_dispatch_next_8u(kmp_Ident *loc, int32_t tid,
586-
int32_t *p_last, uint64_t *p_lb,
587-
uint64_t *p_ub, int64_t *p_st) {
585+
EXTERN int __kmpc_dispatch_next_8u(kmp_Ident *loc, int32_t tid, int32_t *p_last,
586+
uint64_t *p_lb, uint64_t *p_ub,
587+
int64_t *p_st) {
588588
PRINT0(LD_IO, "call kmpc_dispatch_next_8u\n");
589589
return omptarget_nvptx_LoopSupport<uint64_t, int64_t>::dispatch_next(
590590
loc, tid, p_last, p_lb, p_ub, p_st);
@@ -708,10 +708,12 @@ void __kmpc_for_static_init_8u_simple_spmd(kmp_Ident *loc, int32_t global_tid,
708708
}
709709

710710
EXTERN
711-
void __kmpc_for_static_init_4_simple_generic(
712-
kmp_Ident *loc, int32_t global_tid, int32_t schedtype, int32_t *plastiter,
713-
int32_t *plower, int32_t *pupper, int32_t *pstride, int32_t incr,
714-
int32_t chunk) {
711+
void __kmpc_for_static_init_4_simple_generic(kmp_Ident *loc, int32_t global_tid,
712+
int32_t schedtype,
713+
int32_t *plastiter,
714+
int32_t *plower, int32_t *pupper,
715+
int32_t *pstride, int32_t incr,
716+
int32_t chunk) {
715717
PRINT0(LD_IO, "call kmpc_for_static_init_4_simple_generic\n");
716718
omptarget_nvptx_LoopSupport<int32_t, int32_t>::for_static_init(
717719
global_tid, schedtype, plastiter, plower, pupper, pstride, chunk,
@@ -730,10 +732,12 @@ void __kmpc_for_static_init_4u_simple_generic(
730732
}
731733

732734
EXTERN
733-
void __kmpc_for_static_init_8_simple_generic(
734-
kmp_Ident *loc, int32_t global_tid, int32_t schedtype, int32_t *plastiter,
735-
int64_t *plower, int64_t *pupper, int64_t *pstride, int64_t incr,
736-
int64_t chunk) {
735+
void __kmpc_for_static_init_8_simple_generic(kmp_Ident *loc, int32_t global_tid,
736+
int32_t schedtype,
737+
int32_t *plastiter,
738+
int64_t *plower, int64_t *pupper,
739+
int64_t *pstride, int64_t incr,
740+
int64_t chunk) {
737741
PRINT0(LD_IO, "call kmpc_for_static_init_8_simple_generic\n");
738742
omptarget_nvptx_LoopSupport<int64_t, int64_t>::for_static_init(
739743
global_tid, schedtype, plastiter, plower, pupper, pstride, chunk,

openmp/libomptarget/deviceRTLs/common/src/omptarget.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ EXTERN void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized) {
7979
omptarget_nvptx_workFn = 0;
8080
}
8181

82-
EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime) {
82+
EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit,
83+
int16_t RequiresOMPRuntime) {
8384
PRINT0(LD_IO, "call to __kmpc_spmd_kernel_init\n");
8485

8586
setExecutionParameters(Spmd, RequiresOMPRuntime ? RuntimeInitialized

openmp/libomptarget/deviceRTLs/common/src/parallel.cu

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ EXTERN void __kmpc_kernel_end_parallel() {
188188
// If we have the whole warp, reconverge all the threads in the warp before
189189
// actually trying to change the parallel level. Otherwise, parallel level can
190190
// be changed incorrectly because of threads divergence.
191-
bool IsActiveParallelRegion = threadsInTeam != 1;
192-
DecParallelLevel(IsActiveParallelRegion,
193-
IsActiveParallelRegion ? __kmpc_impl_all_lanes : 1u);
191+
bool IsActiveParallelRegion = threadsInTeam != 1;
192+
DecParallelLevel(IsActiveParallelRegion,
193+
IsActiveParallelRegion ? __kmpc_impl_all_lanes : 1u);
194194
}
195195

196196
////////////////////////////////////////////////////////////////////////////////
@@ -281,7 +281,8 @@ EXTERN int32_t __kmpc_global_thread_num(kmp_Ident *loc) {
281281
EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t tid,
282282
int32_t num_threads) {
283283
PRINT(LD_IO, "call kmpc_push_num_threads %d\n", num_threads);
284-
ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), "Runtime must be initialized.");
284+
ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc),
285+
"Runtime must be initialized.");
285286
tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc));
286287
omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(tid) =
287288
num_threads;
@@ -293,12 +294,10 @@ EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t tid,
293294
EXTERN void __kmpc_push_num_teams(kmp_Ident *loc, int32_t tid,
294295
int32_t num_teams, int32_t thread_limit) {
295296
PRINT(LD_IO, "call kmpc_push_num_teams %d\n", (int)num_teams);
296-
ASSERT0(LT_FUSSY, 0,
297-
"should never have anything with new teams on device");
297+
ASSERT0(LT_FUSSY, 0, "should never have anything with new teams on device");
298298
}
299299

300-
EXTERN void __kmpc_push_proc_bind(kmp_Ident *loc, uint32_t tid,
301-
int proc_bind) {
300+
EXTERN void __kmpc_push_proc_bind(kmp_Ident *loc, uint32_t tid, int proc_bind) {
302301
PRINT(LD_IO, "call kmpc_push_proc_bind %d\n", (int)proc_bind);
303302
}
304303

openmp/libomptarget/deviceRTLs/common/src/reduction.cu

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ EXTERN int32_t __kmpc_shuffle_int32(int32_t val, int16_t delta, int16_t size) {
2525
}
2626

2727
EXTERN int64_t __kmpc_shuffle_int64(int64_t val, int16_t delta, int16_t size) {
28-
uint32_t lo, hi;
29-
__kmpc_impl_unpack(val, lo, hi);
30-
hi = __kmpc_impl_shfl_down_sync(__kmpc_impl_all_lanes, hi, delta, size);
31-
lo = __kmpc_impl_shfl_down_sync(__kmpc_impl_all_lanes, lo, delta, size);
32-
return __kmpc_impl_pack(lo, hi);
28+
uint32_t lo, hi;
29+
__kmpc_impl_unpack(val, lo, hi);
30+
hi = __kmpc_impl_shfl_down_sync(__kmpc_impl_all_lanes, hi, delta, size);
31+
lo = __kmpc_impl_shfl_down_sync(__kmpc_impl_all_lanes, lo, delta, size);
32+
return __kmpc_impl_pack(lo, hi);
3333
}
3434

3535
INLINE static void gpu_regular_warp_reduce(void *reduce_data,
@@ -84,16 +84,16 @@ static int32_t nvptx_parallel_reduce_nowait(
8484
uint32_t NumThreads = GetNumberOfOmpThreads(isSPMDExecutionMode);
8585
if (NumThreads == 1)
8686
return 1;
87-
/*
88-
* This reduce function handles reduction within a team. It handles
89-
* parallel regions in both L1 and L2 parallelism levels. It also
90-
* supports Generic, SPMD, and NoOMP modes.
91-
*
92-
* 1. Reduce within a warp.
93-
* 2. Warp master copies value to warp 0 via shared memory.
94-
* 3. Warp 0 reduces to a single value.
95-
* 4. The reduced value is available in the thread that returns 1.
96-
*/
87+
/*
88+
* This reduce function handles reduction within a team. It handles
89+
* parallel regions in both L1 and L2 parallelism levels. It also
90+
* supports Generic, SPMD, and NoOMP modes.
91+
*
92+
* 1. Reduce within a warp.
93+
* 2. Warp master copies value to warp 0 via shared memory.
94+
* 3. Warp 0 reduces to a single value.
95+
* 4. The reduced value is available in the thread that returns 1.
96+
*/
9797

9898
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700
9999
uint32_t WarpsNeeded = (NumThreads + WARPSIZE - 1) / WARPSIZE;

openmp/libomptarget/deviceRTLs/common/src/support.cu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
//===----------------------------------------------------------------------===//
1212
#pragma omp declare target
1313

14-
#include "common/support.h"
1514
#include "common/debug.h"
1615
#include "common/omptarget.h"
16+
#include "common/support.h"
1717

1818
////////////////////////////////////////////////////////////////////////////////
1919
// Execution Parameters
@@ -58,9 +58,7 @@ DEVICE bool checkSPMDMode(kmp_Ident *loc) {
5858
return isSPMDMode();
5959
}
6060

61-
DEVICE bool checkGenericMode(kmp_Ident *loc) {
62-
return !checkSPMDMode(loc);
63-
}
61+
DEVICE bool checkGenericMode(kmp_Ident *loc) { return !checkSPMDMode(loc); }
6462

6563
DEVICE bool checkRuntimeUninitialized(kmp_Ident *loc) {
6664
if (!loc)
@@ -107,7 +105,9 @@ DEVICE bool checkRuntimeInitialized(kmp_Ident *loc) {
107105
// If NumThreads is 1024, master id is 992.
108106
//
109107
// Called in Generic Execution Mode only.
110-
DEVICE int GetMasterThreadID() { return (GetNumberOfThreadsInBlock() - 1) & ~(WARPSIZE - 1); }
108+
DEVICE int GetMasterThreadID() {
109+
return (GetNumberOfThreadsInBlock() - 1) & ~(WARPSIZE - 1);
110+
}
111111

112112
// The last warp is reserved for the master; other warps are workers.
113113
// Called in Generic Execution Mode only.

openmp/libomptarget/deviceRTLs/common/src/task.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "common/omptarget.h"
3232

3333
EXTERN kmp_TaskDescr *__kmpc_omp_task_alloc(
34-
kmp_Ident *loc, // unused
34+
kmp_Ident *loc, // unused
3535
uint32_t global_tid, // unused
3636
int32_t flag, // unused (because in our impl, all are immediately exec
3737
size_t sizeOfTaskInclPrivate, size_t sizeOfSharedTable,

openmp/libomptarget/deviceRTLs/common/state-queuei.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ INLINE uint32_t omptarget_nvptx_Queue<ElementType, SIZE>::DEQUEUE_TICKET() {
2929
}
3030

3131
template <typename ElementType, uint32_t SIZE>
32-
INLINE uint32_t
33-
omptarget_nvptx_Queue<ElementType, SIZE>::ID(uint32_t ticket) {
32+
INLINE uint32_t omptarget_nvptx_Queue<ElementType, SIZE>::ID(uint32_t ticket) {
3433
return (ticket / SIZE) * 2;
3534
}
3635

openmp/libomptarget/deviceRTLs/common/support.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ DEVICE int GetNumberOfWorkersInTeam();
5757

5858
// get OpenMP thread and team ids
5959
DEVICE int GetOmpThreadId(int threadId,
60-
bool isSPMDExecutionMode); // omp_thread_num
61-
DEVICE int GetOmpTeamId(); // omp_team_num
60+
bool isSPMDExecutionMode); // omp_thread_num
61+
DEVICE int GetOmpTeamId(); // omp_team_num
6262

6363
// get OpenMP number of threads and team
6464
DEVICE int GetNumberOfOmpThreads(bool isSPMDExecutionMode); // omp_num_threads

0 commit comments

Comments
 (0)