Skip to content

Commit bacbef1

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent 573af76 commit bacbef1

File tree

273 files changed

+42397
-33780
lines changed

Some content is hidden

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

273 files changed

+42397
-33780
lines changed

arch/arch_device_api.h

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,80 @@
44

55
/* Host-device function declarations */
66
#if (defined(USE_GPU) && (defined(__CUDACC__) || defined(__HIP_PLATFORM_HCC___)))
7-
#define ARCH_HOSTDEV __host__ __device__
7+
#define ARCH_HOSTDEV __host__ __device__
88
#define ARCH_DEV __device__
99
#else
1010
#define ARCH_HOSTDEV
11-
#define ARCH_DEV
11+
#define ARCH_DEV
1212
#endif
1313

1414
/* Namespace for the common loop interface functions */
15-
namespace arch{
16-
/* Type definition used in the headers */
15+
namespace arch {
16+
/* Type definition used in the headers */
1717
typedef uint32_t uint;
18-
/* Enums for different reduction types */
18+
/* Enums for different reduction types */
1919
enum reduce_op { max, min, sum, prod, null };
20-
}
20+
} // namespace arch
2121

2222
/* Select the compiled architecture */
2323
#if defined(USE_GPU) && defined(__CUDACC__)
24-
#include "arch_device_cuda.h"
24+
#include "arch_device_cuda.h"
2525
#elif defined(USE_GPU) && defined(__HIP_PLATFORM_HCC___)
26-
#include "arch_device_hip.h"
26+
#include "arch_device_hip.h"
2727
#else
28-
#include "arch_device_host.h"
28+
#include "arch_device_host.h"
2929
#endif
3030

3131
/* The macro for the inner loop body definition */
3232
#define ARCH_GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
3333
#define ARCH_INNER_BODY(...) ARCH_GET_MACRO(__VA_ARGS__, ARCH_INNER_BODY4, ARCH_INNER_BODY3, ARCH_INNER_BODY2)(__VA_ARGS__)
3434

3535
/* Namespace for the common loop interface functions */
36-
namespace arch{
36+
namespace arch {
3737

38-
/* Parallel reduce interface function - specialization for 1 reduction variable */
39-
template <reduce_op Op, uint NDim, typename Lambda, typename T>
40-
inline static void parallel_reduce(const uint (&limits)[NDim], Lambda loop_body, T &sum) {
38+
/* Parallel reduce interface function - specialization for 1 reduction variable */
39+
template <
40+
reduce_op Op,
41+
uint NDim,
42+
typename Lambda,
43+
typename T>
44+
inline static void parallel_reduce(
45+
const uint (&limits)[NDim],
46+
Lambda loop_body,
47+
T& sum
48+
) {
4149
constexpr uint NReductions = 1;
4250
arch::parallel_reduce_driver<Op, NReductions, NDim>(limits, loop_body, &sum, NReductions);
4351
}
4452

45-
/* Parallel reduce interface function - specialization for a reduction variable array */
46-
template <reduce_op Op, uint NDim, uint NReductions, typename Lambda, typename T>
47-
inline static void parallel_reduce(const uint (&limits)[NDim], Lambda loop_body, T (&sum)[NReductions]) {
53+
/* Parallel reduce interface function - specialization for a reduction variable array */
54+
template <
55+
reduce_op Op,
56+
uint NDim,
57+
uint NReductions,
58+
typename Lambda,
59+
typename T>
60+
inline static void parallel_reduce(
61+
const uint (&limits)[NDim],
62+
Lambda loop_body,
63+
T (&sum)[NReductions]
64+
) {
4865
arch::parallel_reduce_driver<Op, NReductions, NDim>(limits, loop_body, &sum[0], NReductions);
4966
}
5067

51-
/* Parallel reduce interface function - specialization for a reduction variable vector */
52-
template <reduce_op Op, uint NDim, typename Lambda, typename T>
53-
inline static void parallel_reduce(const uint (&limits)[NDim], Lambda loop_body, std::vector<T> &sum) {
68+
/* Parallel reduce interface function - specialization for a reduction variable vector */
69+
template <
70+
reduce_op Op,
71+
uint NDim,
72+
typename Lambda,
73+
typename T>
74+
inline static void parallel_reduce(
75+
const uint (&limits)[NDim],
76+
Lambda loop_body,
77+
std::vector<T>& sum
78+
) {
5479
arch::parallel_reduce_driver<Op, 0, NDim>(limits, loop_body, sum.data(), sum.size());
5580
}
5681

57-
}
82+
} // namespace arch
5883
#endif // !ARCH_DEVICE_API_H

0 commit comments

Comments
 (0)