Apply .clangformat to all repo source files

Change-Id: I7e79c6058f0303f9a98911e3b7dd2e8596079344


[ROCm/hip commit: 1ba06f63c4]
This commit is contained in:
Maneesh Gupta
2018-03-12 11:29:03 +05:30
parent 52506ef382
commit 4f42ee762d
293 changed files with 43980 additions and 45830 deletions
@@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// Test hipEventRecord serialization behavior.
// Through manual inspection of the reported timestamps, can determine if recording a NULL event forces synchronization :
// set
// Through manual inspection of the reported timestamps, can determine if recording a NULL event
// forces synchronization : set
/* HIT_START
* BUILD: %t %s ../../test_common.cpp
@@ -32,82 +32,70 @@ THE SOFTWARE.
#include "hip/hip_runtime.h"
#include "test_common.h"
int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
HipTest::parseStandardArguments(argc, argv, true);
unsigned blocks = (N+threadsPerBlock-1)/threadsPerBlock;
if (blocks > 1024)
blocks = 1024;
if (blocks ==0 )
blocks = 1;
unsigned blocks = (N + threadsPerBlock - 1) / threadsPerBlock;
if (blocks > 1024) blocks = 1024;
if (blocks == 0) blocks = 1;
printf ("N=%zu (A+B+C= %6.1f MB total) blocks=%u threadsPerBlock=%u iterations=%d\n", N, ((double)3*N*sizeof(float))/1024/1024, blocks, threadsPerBlock, iterations);
printf ("iterations=%d\n", iterations);
printf("N=%zu (A+B+C= %6.1f MB total) blocks=%u threadsPerBlock=%u iterations=%d\n", N,
((double)3 * N * sizeof(float)) / 1024 / 1024, blocks, threadsPerBlock, iterations);
printf("iterations=%d\n", iterations);
size_t Nbytes = N*sizeof(float);
size_t Nbytes = N * sizeof(float);
float * A_h, *B_h, *C_h;
float * A_d, *B_d, *C_d;
HipTest::initArrays (&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N);
float *A_h, *B_h, *C_h;
float *A_d, *B_d, *C_d;
HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N);
hipEvent_t start, stop;
// NULL stream check:
HIPCHECK (hipEventCreate(&start));
HIPCHECK (hipEventCreate(&stop));
HIPCHECK(hipEventCreate(&start));
HIPCHECK(hipEventCreate(&stop));
HIPCHECK ( hipMemcpy(A_d, A_h, Nbytes, hipMemcpyHostToDevice));
HIPCHECK ( hipMemcpy(B_d, B_h, Nbytes, hipMemcpyHostToDevice));
HIPCHECK(hipMemcpy(A_d, A_h, Nbytes, hipMemcpyHostToDevice));
HIPCHECK(hipMemcpy(B_d, B_h, Nbytes, hipMemcpyHostToDevice));
for (int i=0; i<iterations; i++) {
for (int i = 0; i < iterations; i++) {
//--- START TIMED REGION
long long hostStart = HipTest::get_time();
// Record the start event
HIPCHECK(hipEventRecord(start, NULL));
//--- START TIMED REGION
long long hostStart = HipTest::get_time();
// Record the start event
HIPCHECK (hipEventRecord(start, NULL));
hipLaunchKernel(
HipTest::vectorADD,
dim3(blocks),
dim3(threadsPerBlock),
0,
0,
static_cast<const float*>(A_d),
static_cast<const float*>(B_d),
C_d,
N);
hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0,
static_cast<const float*>(A_d), static_cast<const float*>(B_d), C_d, N);
HIPCHECK (hipEventRecord(stop, NULL));
HIPCHECK (hipEventSynchronize(stop) );
long long hostStop = HipTest::get_time();
//--- STOP TIMED REGION
HIPCHECK(hipEventRecord(stop, NULL));
HIPCHECK(hipEventSynchronize(stop));
long long hostStop = HipTest::get_time();
//--- STOP TIMED REGION
float eventMs = 1.0f;
HIPCHECK (hipEventElapsedTime(&eventMs, start, stop));
float hostMs = HipTest::elapsed_time(hostStart, hostStop);
float eventMs = 1.0f;
HIPCHECK(hipEventElapsedTime(&eventMs, start, stop));
float hostMs = HipTest::elapsed_time(hostStart, hostStop);
printf ("host_time (gettimeofday) =%6.3fms\n", hostMs);
printf ("kernel_time (hipEventElapsedTime) =%6.3fms\n", eventMs);
printf ("\n");
printf("host_time (gettimeofday) =%6.3fms\n", hostMs);
printf("kernel_time (hipEventElapsedTime) =%6.3fms\n", eventMs);
printf("\n");
// Make sure timer is timing something...
HIPASSERT(eventMs > 0.0f);
}
// Make sure timer is timing something...
HIPASSERT(eventMs > 0.0f);
}
HIPCHECK (hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost));
HIPCHECK(hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost));
printf ("check:\n");
printf("check:\n");
HipTest::checkVectorADD(A_h, B_h, C_h, N, true);
passed();
}
@@ -33,7 +33,7 @@ enum SyncMode {
};
const char *syncModeString(int syncMode) {
const char* syncModeString(int syncMode) {
switch (syncMode) {
case syncNone:
return "syncNone";
@@ -47,24 +47,24 @@ const char *syncModeString(int syncMode) {
};
void test(unsigned testMask, int *C_d, int *C_h, int64_t numElements, hipStream_t stream, int waitStart, SyncMode syncMode)
{
void test(unsigned testMask, int* C_d, int* C_h, int64_t numElements, hipStream_t stream,
int waitStart, SyncMode syncMode) {
if (!(testMask & p_tests)) {
return;
}
printf ("\ntest 0x%3x: stream=%p waitStart=%d syncMode=%s\n",
testMask, stream, waitStart, syncModeString(syncMode));
printf("\ntest 0x%3x: stream=%p waitStart=%d syncMode=%s\n", testMask, stream, waitStart,
syncModeString(syncMode));
size_t sizeBytes = numElements * sizeof(int);
int count =100;
int count = 100;
int init0 = 0;
HIPCHECK(hipMemset(C_d, init0, sizeBytes));
for (int i=0; i<numElements; i++) {
C_h[i] = -1; // initialize
for (int i = 0; i < numElements; i++) {
C_h[i] = -1; // initialize
}
hipEvent_t neverCreated=0, neverRecorded, timingDisabled;
hipEvent_t neverCreated = 0, neverRecorded, timingDisabled;
HIPCHECK(hipEventCreate(&neverRecorded));
HIPCHECK(hipEventCreateWithFlags(&timingDisabled, hipEventDisableTiming));
@@ -77,16 +77,8 @@ void test(unsigned testMask, int *C_d, int *C_h, int64_t numElements, hipStream_
HIPCHECK(hipEventRecord(timingDisabled, stream));
// sandwhich a kernel:
HIPCHECK(hipEventRecord(start, stream));
hipLaunchKernelGGL(
HipTest::addCountReverse,
dim3(blocks),
dim3(threadsPerBlock),
0,
stream,
static_cast<const int*>(C_d),
C_h,
numElements,
count);
hipLaunchKernelGGL(HipTest::addCountReverse, dim3(blocks), dim3(threadsPerBlock), 0, stream,
static_cast<const int*>(C_d), C_h, numElements, count);
HIPCHECK(hipEventRecord(stop, stream));
@@ -116,32 +108,27 @@ void test(unsigned testMask, int *C_d, int *C_h, int64_t numElements, hipStream_
float t;
hipError_t e = hipEventElapsedTime(&t, start, start);
if ((e != hipSuccess) && (e != hipErrorNotReady)) {
failed ("start event not in expected state, was %d=%s\n", e, hipGetErrorName(e));
if ((e != hipSuccess) && (e != hipErrorNotReady)) {
failed("start event not in expected state, was %d=%s\n", e, hipGetErrorName(e));
}
if (e == hipSuccess)
assert (t==0.0f);
if (e == hipSuccess) assert(t == 0.0f);
// stop usually ready unless we skipped the synchronization (syncNone)
HIPCHECK_API(hipEventElapsedTime(&t, stop, stop), expectedStopError);
if (e == hipSuccess)
assert (t==0.0f);
if (e == hipSuccess) assert(t == 0.0f);
e = hipEventElapsedTime(&t, start, stop);
HIPCHECK_API(e, expectedStopError);
if (expectedStopError == hipSuccess)
assert (t>0.0f);
printf ("time=%6.2f error=%s\n", t, hipGetErrorName(e));
if (expectedStopError == hipSuccess) assert(t > 0.0f);
printf("time=%6.2f error=%s\n", t, hipGetErrorName(e));
e = hipEventElapsedTime(&t, stop, start);
HIPCHECK_API(e, expectedStopError);
if (expectedStopError == hipSuccess)
assert (t<0.0f);
printf ("negtime=%6.2f error=%s\n", t, hipGetErrorName(e));
if (expectedStopError == hipSuccess) assert(t < 0.0f);
printf("negtime=%6.2f error=%s\n", t, hipGetErrorName(e));
{
@@ -150,10 +137,10 @@ void test(unsigned testMask, int *C_d, int *C_h, int64_t numElements, hipStream_
HIPCHECK_API(hipEventElapsedTime(&t, start, timingDisabled), hipErrorInvalidResourceHandle);
HIPCHECK_API(hipEventElapsedTime(&t, neverCreated, stop), hipErrorInvalidResourceHandle);
HIPCHECK_API(hipEventElapsedTime(&t, start, neverCreated), hipErrorInvalidResourceHandle);
HIPCHECK_API(hipEventElapsedTime(&t, start, neverCreated), hipErrorInvalidResourceHandle);
HIPCHECK_API(hipEventElapsedTime(&t, neverRecorded, stop), hipErrorInvalidResourceHandle);
HIPCHECK_API(hipEventElapsedTime(&t, start, neverRecorded), hipErrorInvalidResourceHandle);
HIPCHECK_API(hipEventElapsedTime(&t, start, neverRecorded), hipErrorInvalidResourceHandle);
}
HIPCHECK(hipEventDestroy(start));
@@ -162,16 +149,15 @@ void test(unsigned testMask, int *C_d, int *C_h, int64_t numElements, hipStream_
// Clear out everything:
HIPCHECK(hipDeviceSynchronize());
printf ("test: OK \n");
printf("test: OK \n");
}
void runTests(int64_t numElements)
{
void runTests(int64_t numElements) {
size_t sizeBytes = numElements * sizeof(int);
printf ("test: starting sequence with sizeBytes=%zu bytes, %6.2f MB\n", sizeBytes, sizeBytes/1024.0/1024.0);
printf("test: starting sequence with sizeBytes=%zu bytes, %6.2f MB\n", sizeBytes,
sizeBytes / 1024.0 / 1024.0);
int *C_h, *C_d;
@@ -181,15 +167,15 @@ void runTests(int64_t numElements)
hipStream_t stream;
HIPCHECK(hipStreamCreateWithFlags(&stream, 0x0));
//for (int waitStart=0; waitStart<2; waitStart++) {
for (int waitStart=1; waitStart>=0; waitStart--) {
unsigned W = waitStart ? 0x1000:0;
test (W | 0x01, C_d, C_h, numElements, 0 , waitStart, syncNone);
test (W | 0x02, C_d, C_h, numElements, stream, waitStart, syncNone);
test (W | 0x04, C_d, C_h, numElements, 0 , waitStart, syncStream);
test (W | 0x08, C_d, C_h, numElements, stream, waitStart, syncStream);
test (W | 0x10, C_d, C_h, numElements, 0, waitStart, syncStopEvent);
test (W | 0x20, C_d, C_h, numElements, stream, waitStart, syncStopEvent);
// for (int waitStart=0; waitStart<2; waitStart++) {
for (int waitStart = 1; waitStart >= 0; waitStart--) {
unsigned W = waitStart ? 0x1000 : 0;
test(W | 0x01, C_d, C_h, numElements, 0, waitStart, syncNone);
test(W | 0x02, C_d, C_h, numElements, stream, waitStart, syncNone);
test(W | 0x04, C_d, C_h, numElements, 0, waitStart, syncStream);
test(W | 0x08, C_d, C_h, numElements, stream, waitStart, syncStream);
test(W | 0x10, C_d, C_h, numElements, 0, waitStart, syncStopEvent);
test(W | 0x20, C_d, C_h, numElements, stream, waitStart, syncStopEvent);
}
@@ -199,8 +185,7 @@ void runTests(int64_t numElements)
}
int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
HipTest::parseStandardArguments(argc, argv, true /*failOnUndefinedArg*/);
runTests(80000000);