Skip to content

Commit d39859c

Browse files
committed
GPU: Apply clang-format or suppress it
1 parent dcadffb commit d39859c

28 files changed

Lines changed: 68 additions & 73 deletions

‎.clang-format‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ IndentWidth: 2
2727
# It is broken on windows. Breaks all #include "header.h"
2828
---
2929
Language: Cpp
30+
AttributeMacros: ['GPUrestrict'] # GPU qualifier macro: GPUrestrict() is otherwise parsed as function call, e.g. 'a -> b' after it
3031
MaxEmptyLinesToKeep: 1
3132
KeepEmptyLinesAtTheStartOfBlocks: true
3233
NamespaceIndentation: None

‎GPU/Common/GPUCommonArray.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ struct array {
4141
}
4242
T m_internal_V__[N];
4343
};
44+
// clang-format off
4445
template <class T, class... E>
4546
GPUd() array(T, E...)->array<T, 1 + sizeof...(E)>;
47+
// clang-format on
4648
#else
4749
template <typename T, size_t N>
4850
using array = std::array<T, N>;

‎GPU/Common/GPUCommonConstants.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ namespace o2::gpu::gpu_common_constants
2121
{
2222
static GPUglobalconstexpr() const float kCLight = 0.000299792458f; // TODO: Duplicate of MathConstants, fix this now that we use only OpenCL CPP
2323
static GPUglobalconstexpr() const float kZeroFieldCut = 0.013f;
24-
}
24+
} // namespace o2::gpu::gpu_common_constants
2525

2626
#endif

‎GPU/GPUTracking/Base/GPUReconstructionKernelIncludes.template.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414

1515
// clang-format off
1616
$<JOIN:$<LIST:TRANSFORM,$<LIST:TRANSFORM,$<LIST:REMOVE_DUPLICATES,$<TARGET_PROPERTY:O2_GPU_KERNELS,O2_GPU_KERNEL_INCLUDES>>,APPEND,.h">,PREPEND,#include ">,
17-
>
18-
// clang-format on
17+
> // clang-format on

‎GPU/GPUTracking/Base/GPUReconstructionKernelList.template.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616
#include "GPUReconstructionKernelMacros.h"
1717

1818
// clang-format off
19-
$<JOIN:$<TARGET_PROPERTY:O2_GPU_KERNELS,O2_GPU_KERNELS>,>
20-
// clang-format on
19+
$<JOIN:$<TARGET_PROPERTY:O2_GPU_KERNELS,O2_GPU_KERNELS>,> // clang-format on

‎GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ int32_t GPUReconstructionCUDA::InitDevice_Runtime()
331331
}
332332
}
333333

334-
#ifndef __HIPCC__ // CUDA
334+
#ifndef __HIPCC__ // CUDA
335335
dummyInitKernel<<<mMultiprocessorCount, 256>>>(mDeviceMemoryBase); // TODO: Can't we just use the CUDA version and hipify will take care of the rest?
336-
#else // HIP
336+
#else // HIP
337337
hipLaunchKernelGGL(HIP_KERNEL_NAME(dummyInitKernel), dim3(mMultiprocessorCount), dim3(256), 0, 0, mDeviceMemoryBase);
338338
#endif
339339

‎GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAkernel.template.cu‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121

2222
// clang-format off
2323
@O2_GPU_KERNEL_TEMPLATE_FILES@
24-
// clang-format on
2524

2625
extern "C" {
27-
// clang-format off
2826
@O2_GPU_KERNEL_TEMPLATE_REPLACE@
29-
// clang-format on
30-
}
27+
} // clang-format on: not before the }, the placeholders confuse clang-format

‎GPU/GPUTracking/Base/hip/GPUReconstructionHIPkernel.template.hip‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121

2222
// clang-format off
2323
@O2_GPU_KERNEL_TEMPLATE_FILES@
24-
// clang-format on
2524

2625
extern "C" {
27-
// clang-format off
2826
@O2_GPU_KERNEL_TEMPLATE_REPLACE@
29-
// clang-format on
30-
}
27+
} // clang-format on: not before the }, the placeholders confuse clang-format

‎GPU/GPUTracking/DataCompression/GPUTPCCompressionKernels.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ GPUdii() void GPUTPCCompressionKernels::Thread<GPUTPCCompressionKernels::step0at
6767
if (!(param.rec.tpc.compressionTypeMask & GPUSettings::CompressionTrackModel)) {
6868
continue; // No track model compression
6969
}
70-
const ClusterNative& GPUrestrict() orgCl = clusters -> clusters[hit.sector][hit.row][hit.num - clusters->clusterOffset[hit.sector][hit.row]];
70+
const ClusterNative& GPUrestrict() orgCl = clusters->clusters[hit.sector][hit.row][hit.num - clusters->clusterOffset[hit.sector][hit.row]];
7171
constexpr GPUTPCGeometry geo;
7272
float x = geo.Row2X(hit.row);
7373
float y = track.LinearPad2Y(hit.sector, orgCl.getPad(), geo.PadWidth(hit.row), geo.NPads(hit.row));
@@ -291,7 +291,7 @@ GPUdii() void GPUTPCCompressionKernels::Thread<GPUTPCCompressionKernels::step1un
291291

292292
for (uint32_t j = get_local_id(0); j < count; j += get_local_size(0)) {
293293
int32_t outidx = idOffsetOut + totalCount + j;
294-
const ClusterNative& GPUrestrict() orgCl = clusters -> clusters[iSector][iRow][sortBuffer[j]];
294+
const ClusterNative& GPUrestrict() orgCl = clusters->clusters[iSector][iRow][sortBuffer[j]];
295295

296296
int32_t preId = j != 0 ? (int32_t)sortBuffer[j - 1] : (totalCount != 0 ? (int32_t)smem.lastIndex : -1);
297297
GPUTPCCompression_EncodeUnattached(param.rec.tpc.compressionTypeMask, orgCl, c.timeDiffU[outidx], c.padDiffU[outidx], preId == -1 ? nullptr : &clusters->clusters[iSector][iRow][preId]);

‎GPU/GPUTracking/DataTypes/GPUTPCGeometry.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class GPUTPCGeometry
121121
GPUd() static constexpr int32_t MaxNPadsPerRow() { return 138; }
122122
GPUd() static constexpr float PadWidth(int32_t row) { return (gputpcgeometry_internal::mPadWidthRow[row]); }
123123
#else
124-
GPUd() static constexpr int32_t GetRegion(int32_t row) { return (row < 63 ? 0 : row < 63 + 64 ? 1 : 2); }
124+
GPUd() static constexpr int32_t GetRegion(int32_t row) { return (row < 63 ? 0 : (row < 63 + 64 ? 1 : 2)); }
125125
GPUd() static constexpr int32_t GetRegionRows(int32_t region) { return 0; } // dummy
126126
GPUd() static constexpr int32_t GetRegionStart(int32_t region) { return 0; } // dummy
127127
GPUd() static constexpr int32_t GetROC(int32_t row) { return GetRegion(row); }

0 commit comments

Comments
 (0)