Apply consistent code formatting across the repo. Add clang-format and pre-commit hooks.

This commit is contained in:
Rob Armstrong
2025-03-27 10:30:07 -07:00
parent 2cd58fbc9a
commit ceab6e8bcc
782 changed files with 107230 additions and 106548 deletions

View File

@@ -65,25 +65,27 @@
// This is the un-specialized struct. Note that we prevent instantiation of
// this struct by making it abstract (i.e. with pure virtual methods).
template <typename T>
struct SharedMemory {
// Ensure that we won't compile any un-specialized types
virtual __device__ T &operator*() = 0;
virtual __device__ T &operator[](int i) = 0;
template <typename T> struct SharedMemory
{
// Ensure that we won't compile any un-specialized types
virtual __device__ T &operator*() = 0;
virtual __device__ T &operator[](int i) = 0;
};
#define BUILD_SHAREDMEMORY_TYPE(t, n) \
template <> \
struct SharedMemory<t> { \
__device__ t &operator*() { \
extern __shared__ t n[]; \
return *n; \
} \
__device__ t &operator[](int i) { \
extern __shared__ t n[]; \
return n[i]; \
} \
}
#define BUILD_SHAREDMEMORY_TYPE(t, n) \
template <> struct SharedMemory<t> \
{ \
__device__ t &operator*() \
{ \
extern __shared__ t n[]; \
return *n; \
} \
__device__ t &operator[](int i) \
{ \
extern __shared__ t n[]; \
return n[i]; \
} \
}
BUILD_SHAREDMEMORY_TYPE(int, s_int);
BUILD_SHAREDMEMORY_TYPE(unsigned int, s_uint);

View File

@@ -28,18 +28,17 @@
#ifndef PIESTIMATOR_H
#define PIESTIMATOR_H
template <typename Real>
class PiEstimator {
public:
PiEstimator(unsigned int numSims, unsigned int device,
unsigned int threadBlockSize, unsigned int seed);
Real operator()();
template <typename Real> class PiEstimator
{
public:
PiEstimator(unsigned int numSims, unsigned int device, unsigned int threadBlockSize, unsigned int seed);
Real operator()();
private:
unsigned int m_seed;
unsigned int m_numSims;
unsigned int m_device;
unsigned int m_threadBlockSize;
private:
unsigned int m_seed;
unsigned int m_numSims;
unsigned int m_device;
unsigned int m_threadBlockSize;
};
#endif

View File

@@ -28,30 +28,31 @@
#ifndef TEST_H
#define TEST_H
template <typename Real>
struct Test {
Test() : pass(false){};
template <typename Real> struct Test
{
Test()
: pass(false) {};
int device;
unsigned int numSims;
unsigned int threadBlockSize;
unsigned int seed;
int device;
unsigned int numSims;
unsigned int threadBlockSize;
unsigned int seed;
bool pass;
double elapsedTime;
bool pass;
double elapsedTime;
bool operator()();
bool operator()();
};
// Defaults are arbitrary to give sensible runtime
#define k_sims_min 100000
#define k_sims_max 10000000
#define k_sims_def 100000
#define k_sims_qa 100000
#define k_sims_min 100000
#define k_sims_max 10000000
#define k_sims_def 100000
#define k_sims_qa 100000
#define k_bsize_min 32
#define k_bsize_def 128
#define k_bsize_qa 128
#define k_seed_def 1234
#define k_bsize_qa 128
#define k_seed_def 1234
// Target value
#define PI 3.14159265359