Apply .clangformat to all repo source files

Change-Id: I7e79c6058f0303f9a98911e3b7dd2e8596079344
This commit is contained in:
Maneesh Gupta
2018-03-12 11:29:03 +05:30
parent 18e70b1e6b
commit 1ba06f63c4
293 changed files with 43980 additions and 45830 deletions
@@ -33,8 +33,7 @@ THE SOFTWARE.
bool p_async = false;
// ****************************************************************************
hipError_t memcopy(void * dst, const void *src, size_t sizeBytes, enum hipMemcpyKind kind)
{
hipError_t memcopy(void* dst, const void* src, size_t sizeBytes, enum hipMemcpyKind kind) {
if (p_async) {
return hipMemcpyAsync(dst, src, sizeBytes, kind, NULL);
} else {
@@ -46,59 +45,50 @@ hipError_t memcopy(void * dst, const void *src, size_t sizeBytes, enum hipMemcpy
//---
// Test simple H2D copies and back.
// Designed to stress a small number of simple smoke tests
void simpleTest1()
{
printf ("test: %s\n", __func__);
size_t Nbytes = N*sizeof(int);
printf ("N=%zu Nbytes=%6.2fMB\n", N, Nbytes/1024.0/1024.0);
void simpleTest1() {
printf("test: %s\n", __func__);
size_t Nbytes = N * sizeof(int);
printf("N=%zu Nbytes=%6.2fMB\n", N, Nbytes / 1024.0 / 1024.0);
int *A_d, *B_d, *C_d;
int *A_h, *B_h, *C_h;
HipTest::initArrays (&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false);
HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false);
printf ("A_d=%p B_d=%p C_d=%p A_h=%p B_h=%p C_h=%p\n", A_d, B_d, C_d, A_h, B_d, C_h);
printf("A_d=%p B_d=%p C_d=%p A_h=%p B_h=%p C_h=%p\n", A_d, B_d, C_d, A_h, B_d, C_h);
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, N);
HIPCHECK ( memcopy(A_d, A_h, Nbytes, hipMemcpyHostToDevice));
HIPCHECK ( memcopy(B_d, B_h, Nbytes, hipMemcpyHostToDevice));
HIPCHECK(memcopy(A_d, A_h, Nbytes, hipMemcpyHostToDevice));
HIPCHECK(memcopy(B_d, B_h, Nbytes, hipMemcpyHostToDevice));
hipLaunchKernel(
HipTest::vectorADD,
dim3(blocks),
dim3(threadsPerBlock),
0,
0,
static_cast<const int*>(A_d),
static_cast<const int*>(B_d),
C_d,
N);
hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0,
static_cast<const int*>(A_d), static_cast<const int*>(B_d), C_d, N);
HIPCHECK ( memcopy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost));
HIPCHECK(memcopy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost));
HIPCHECK (hipDeviceSynchronize());
HIPCHECK(hipDeviceSynchronize());
HipTest::checkVectorADD(A_h, B_h, C_h, N);
HipTest::freeArrays (A_d, B_d, C_d, A_h, B_h, C_h, false);
HIPCHECK (hipDeviceReset());
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
HIPCHECK(hipDeviceReset());
printf (" %s success\n", __func__);
printf(" %s success\n", __func__);
}
template <typename T>
void simpleTest2(size_t numElements, bool usePinnedHost)
{
void simpleTest2(size_t numElements, bool usePinnedHost) {
size_t sizeElements = numElements * sizeof(T);
size_t alignment = 4096;
printf ("test: %s<%s> numElements=%zu sizeElements=%zu bytes\n", __func__, TYPENAME(T), numElements, sizeElements);
printf("test: %s<%s> numElements=%zu sizeElements=%zu bytes\n", __func__, TYPENAME(T),
numElements, sizeElements);
T *A_d, *A_h1, *A_h2;
if (usePinnedHost) {
HIPCHECK ( hipHostMalloc((void**)&A_h1, sizeElements, hipHostMallocDefault) );
HIPCHECK ( hipHostMalloc((void**)&A_h2, sizeElements, hipHostMallocDefault) );
HIPCHECK(hipHostMalloc((void**)&A_h1, sizeElements, hipHostMallocDefault));
HIPCHECK(hipHostMalloc((void**)&A_h2, sizeElements, hipHostMallocDefault));
} else {
A_h1 = (T*)aligned_alloc(alignment, sizeElements);
HIPASSERT(A_h1);
@@ -107,12 +97,13 @@ void simpleTest2(size_t numElements, bool usePinnedHost)
}
// Alloc device array:
HIPCHECK ( hipMalloc(&A_d, sizeElements) );
HIPCHECK(hipMalloc(&A_d, sizeElements));
for (size_t i=0; i<numElements; i++) {
A_h1[i] = 3.14f+ 1000*i;
A_h2[i] = 12345678.0 + i; // init output with something distincctive, to ensure we replace it.
for (size_t i = 0; i < numElements; i++) {
A_h1[i] = 3.14f + 1000 * i;
A_h2[i] =
12345678.0 + i; // init output with something distincctive, to ensure we replace it.
}
HIPCHECK(memcopy(A_d, A_h1, sizeElements, hipMemcpyHostToDevice));
@@ -120,7 +111,7 @@ void simpleTest2(size_t numElements, bool usePinnedHost)
HIPCHECK(memcopy(A_h2, A_d, sizeElements, hipMemcpyDeviceToHost));
HIPCHECK(hipDeviceSynchronize());
for (size_t i=0; i<numElements; i++) {
for (size_t i = 0; i < numElements; i++) {
HIPASSERT(A_h1[i] == A_h2[i]);
}
@@ -135,14 +126,13 @@ void simpleTest2(size_t numElements, bool usePinnedHost)
}
//Parse arguments specific to this test.
void parseMyArguments(int argc, char *argv[])
{
// Parse arguments specific to this test.
void parseMyArguments(int argc, char* argv[]) {
int more_argc = HipTest::parseStandardArguments(argc, argv, false);
// parse args for this test:
for (int i = 1; i < more_argc; i++) {
const char *arg = argv[i];
const char* arg = argv[i];
if (!strcmp(arg, "--async")) {
p_async = true;
@@ -154,31 +144,30 @@ void parseMyArguments(int argc, char *argv[])
};
int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
parseMyArguments(argc, argv);
printf ("info: set device to %d, tests=%x\n", p_gpuDevice, p_tests);
printf("info: set device to %d, tests=%x\n", p_gpuDevice, p_tests);
HIPCHECK(hipSetDevice(p_gpuDevice));
if (p_tests & 0x1) {
printf ("\n\n=== tests&1\n");
HIPCHECK ( hipDeviceReset() );
printf("\n\n=== tests&1\n");
HIPCHECK(hipDeviceReset());
simpleTest1();
printf ("===\n\n\n");
printf("===\n\n\n");
}
if (p_tests & 0x2) {
printf ("\n\n=== tests&2 (copy ping-pong, pinned host)\n");
simpleTest2<float>(N, true/*usePinnedHost*/);
simpleTest2<char>(N, true/*usePinnedHost*/);
printf("\n\n=== tests&2 (copy ping-pong, pinned host)\n");
simpleTest2<float>(N, true /*usePinnedHost*/);
simpleTest2<char>(N, true /*usePinnedHost*/);
}
if (p_tests & 0x4) {
printf ("\n\n=== tests&4 (copy ping-pong, unpinned host)\n");
simpleTest2<char>(N, false/*usePinnedHost*/);
simpleTest2<float>(N, false/*usePinnedHost*/);
printf("\n\n=== tests&4 (copy ping-pong, unpinned host)\n");
simpleTest2<char>(N, false /*usePinnedHost*/);
simpleTest2<float>(N, false /*usePinnedHost*/);
}
hipDeviceSynchronize();