hcc_dialects report PASSED when passed

This commit is contained in:
Maneesh Gupta
2016-05-03 14:32:59 +05:30
parent fb88bb1c17
commit 07026bfdea
6 changed files with 18 additions and 0 deletions
@@ -16,6 +16,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int sizeElements = 1000000; int sizeElements = 1000000;
bool pass = true;
// Allocate auto-managed host/device views of data: // Allocate auto-managed host/device views of data:
concurrency::array_view<float> A(sizeElements); concurrency::array_view<float> A(sizeElements);
@@ -43,6 +44,8 @@ int main(int argc, char *argv[])
// Because C is an array_view, the HCC runtime will copy C back to host at first access here: // Because C is an array_view, the HCC runtime will copy C back to host at first access here:
if (C[i] != ref) { if (C[i] != ref) {
printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C[i], ref); printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C[i], ref);
pass = false;
} }
}; };
if (pass) printf ("PASSED!\n");
} }
@@ -11,6 +11,7 @@ int main(int argc, char *argv[])
{ {
int sizeElements = 1000000; int sizeElements = 1000000;
size_t sizeBytes = sizeElements * sizeof(float); size_t sizeBytes = sizeElements * sizeof(float);
bool pass = true;
// Allocate host memory // Allocate host memory
float *A_h = (float*)malloc(sizeBytes); float *A_h = (float*)malloc(sizeBytes);
@@ -54,6 +55,8 @@ int main(int argc, char *argv[])
float ref= 1.618f * i + 3.142f * i; float ref= 1.618f * i + 3.142f * i;
if (C_h[i] != ref) { if (C_h[i] != ref) {
printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C_h[i], ref); printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C_h[i], ref);
pass = false;
} }
}; };
if (pass) printf ("PASSED!\n");
} }
@@ -11,6 +11,7 @@ int main(int argc, char *argv[])
{ {
int sizeElements = 1000000; int sizeElements = 1000000;
size_t sizeBytes = sizeElements * sizeof(float); size_t sizeBytes = sizeElements * sizeof(float);
bool pass = true;
// Allocate host memory // Allocate host memory
float *A_h = (float*)malloc(sizeBytes); float *A_h = (float*)malloc(sizeBytes);
@@ -48,6 +49,8 @@ int main(int argc, char *argv[])
float ref= 1.618f * i + 3.142f * i; float ref= 1.618f * i + 3.142f * i;
if (C_h[i] != ref) { if (C_h[i] != ref) {
printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C_h[i], ref); printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C_h[i], ref);
pass = false;
} }
}; };
if (pass) printf ("PASSED!\n");
} }
@@ -3,6 +3,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int size = 1000000; int size = 1000000;
bool pass = true;
// Allocate auto-managed host/device views of data: // Allocate auto-managed host/device views of data:
hc::array_view<float> A(size); hc::array_view<float> A(size);
@@ -28,6 +29,8 @@ int main(int argc, char *argv[])
float ref= 1.618f * i + 3.142f * i; float ref= 1.618f * i + 3.142f * i;
if (C[i] != ref) { if (C[i] != ref) {
printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C[i], ref); printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C[i], ref);
pass = false;
} }
}; };
if (pass) printf ("PASSED!\n");
} }
@@ -16,6 +16,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int sizeElements = 1000000; int sizeElements = 1000000;
bool pass = true;
// Allocate auto-managed host/device views of data: // Allocate auto-managed host/device views of data:
hc::array_view<float> A(sizeElements); hc::array_view<float> A(sizeElements);
@@ -43,6 +44,8 @@ int main(int argc, char *argv[])
// Because C is an array_view, the HCC runtime will copy C back to host at first access here: // Because C is an array_view, the HCC runtime will copy C back to host at first access here:
if (C[i] != ref) { if (C[i] != ref) {
printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C[i], ref); printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C[i], ref);
pass = false;
} }
}; };
if (pass) printf ("PASSED!\n");
} }
@@ -14,6 +14,7 @@ int main(int argc, char *argv[])
{ {
int sizeElements = 1000000; int sizeElements = 1000000;
size_t sizeBytes = sizeElements * sizeof(float); size_t sizeBytes = sizeElements * sizeof(float);
bool pass = true;
// Allocate host memory // Allocate host memory
float *A_h = (float*)malloc(sizeBytes); float *A_h = (float*)malloc(sizeBytes);
@@ -46,6 +47,8 @@ int main(int argc, char *argv[])
float ref= 1.618f * i + 3.142f * i; float ref= 1.618f * i + 3.142f * i;
if (C_h[i] != ref) { if (C_h[i] != ref) {
printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C_h[i], ref); printf ("error:%d computed=%6.2f, reference=%6.2f\n", i, C_h[i], ref);
pass = false;
} }
}; };
if (pass) printf ("PASSED!\n");
} }