Skip to content

Commit

Permalink
Merge pull request #20 from ajarmusch/master
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
ajarmusch authored Sep 23, 2022
2 parents 7d67060 + b1509af commit cf6f24e
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 26 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# OpenACCV-V
This repository is updated with OpenACC test codes validating and verifying implementations of features and its conformance to the OpenACC specification. We are continuously adding and editing tests to conform to the latest version of the [OpenACC Specification](https://www.openacc.org/specification).

Consult our website for more details on results and our project [OpenACC V&V Website](https://crpl.cis.udel.edu/oaccvv/).

## Executing program

In order to run the suite, we have provided a Python script, infrastructure.py that can be run. It is recommended to use Python 3.3 or later. Once Python has been loaded into your environment, the script can be invoked with the command
Expand Down
106 changes: 80 additions & 26 deletions Tests/parallel_loop_auto.c
Original file line number Diff line number Diff line change
@@ -1,68 +1,113 @@
#include "acc_testsuite.h"
#ifndef T1
//T1:parallel,loop,combined-constructs,syntactic,V:2.0-2.7
//data independent, treated as a independent clause
int test1(){
int err = 0;
srand(SEED);
real_t * a = (real_t *)malloc(n * sizeof(real_t));
real_t * a_copy = (real_t *)malloc(n * sizeof(real_t));
real_t * b = (real_t *)malloc(n * sizeof(real_t));
real_t * value = (real_t *)malloc(n * sizeof(real_t));
real_t * empty = (real_t *)malloc(n * sizeof(real_t));

for (int x = 0; x < n; ++x){
a[x] = rand() / (real_t)(RAND_MAX / 10);
b[x] = 0;
value[x] = rand() / (real_t)(RAND_MAX / 10);
empty[x] = 0;
}

#pragma acc data copyin(a[0:n]) copyout(b[0:n])
#pragma acc data copyin(value[0:n]) copy(empty[0:n])
{
#pragma acc parallel loop auto
for (int x = 0; x < n; ++x){
b[x] = a[x];
empty[x] = value[x];
}
}

for (int x = 0; x < n; ++x){
if (fabs(b[x] - a[x]) > PRECISION){
if (fabs(empty[x] - value[x]) > PRECISION){
err = 1;
}
}

free(value);
free(empty);

return err;
}
#endif

#ifndef T2
//T2:parallel,loop,combined-constructs,V:2.0-2.7
int test2(){
//T2:parallel,loop,combined-constructs,syntactic,V:2.0-2.7
//data dependent, treated with as a seq clause. Added the num_gangs clause with 1
int test3(){
int err = 0;
srand(SEED);
real_t * a = (real_t *)malloc(n * sizeof(real_t));
real_t * a_copy = (real_t *)malloc(n * sizeof(real_t));
real_t * b = (real_t *)malloc(n * sizeof(real_t));
real_t * device = (real_t *)malloc(n * sizeof(real_t));
real_t * host = (real_t *)malloc(n * sizeof(real_t));

for (int x = 0; x < n; ++x){
a[x] = rand() / (real_t)(RAND_MAX / 10);
a_copy[x] = a[x];
device[x] = rand() / (real_t)(RAND_MAX / 10);
host[x] = device[x];
}

#pragma acc data copy(a[0:n])
#pragma acc data copy(device[0:n])
{
#pragma acc parallel loop auto
#pragma acc parallel loop num_gangs(1) auto
for (int x = 1; x < n; ++x){
device[x] = device[x - 1] + device[x];
}
}

real_t rolling_total = 0.0;
for (int x = 0; x < n; ++x){
rolling_total += host[x];
if (fabs(rolling_total - device[x]) > PRECISION){
err = 1;
}
}

free(device);
free(host);

return err;
}
#endif

#ifndef T3
//T3:parallel,loop,combined-constructs,V:2.0-2.7
//data dependent, treated with as a seq clause.
int test3(){
int err = 0;
srand(SEED);
real_t * device = (real_t *)malloc(n * sizeof(real_t));
real_t * host = (real_t *)malloc(n * sizeof(real_t));

for (int x = 0; x < n; ++x){
device[x] = rand() / (real_t)(RAND_MAX / 10);
host[x] = device[x];
}

#pragma acc data copy(device[0:n])
{
#pragma acc parallel loop num_gangs(1) vector worker auto
for (int x = 1; x < n; ++x){
a[x] = a[x - 1] + a[x];
device[x] = device[x - 1] + device[x];
}
}

real_t rolling_total = 0.0;
for (int x = 0; x < n; ++x){
rolling_total += a_copy[x];
if (fabs(rolling_total - a[x]) > PRECISION){
rolling_total += host[x];
if (fabs(rolling_total - device[x]) > PRECISION){
err = 1;
}
}

free(device);
free(host);

return err;
}


#endif

int main(){
Expand All @@ -71,19 +116,28 @@ int main(){
#ifndef T1
failed = 0;
for (int x = 0; x < NUM_TEST_CALLS; ++x){
failed = failed + test1();
failed += test1();
}
if (failed != 0){
failcode = failcode + (1 << 0);
if (failed){
failcode += (1 << 0);
}
#endif
#ifndef T2
failed = 0;
for (int x = 0; x < NUM_TEST_CALLS; ++x){
failed = failed + test2();
failed += test2();
}
if (failed){
failcode += (1 << 1);
}
#endif
#ifndef T3
failed = 0;
for (int x = 0; x < NUM_TEST_CALLS; ++x){
failed += test3();
}
if (failed != 0){
failcode = failcode + (1 << 1);
if (failed){
failcode += (1 << 2);
}
#endif
return failcode;
Expand Down

0 comments on commit cf6f24e

Please sign in to comment.