Dataset Viewer
Auto-converted to Parquet Duplicate
file_path
stringlengths
17
84
content
stringlengths
235
1.29M
./make_dataset.py
import os from datasets import Dataset from huggingface_hub import HfApi # Define paths and parameters data_dir = "." # Path to your folder containing subfolders with code files dataset_name = "chrismun/llm4vv-test" # Replace with your Hugging Face username and desired dataset name # Function to read files recursively and create dataset def read_files_recursively(data_dir): data = {"file_path": [], "content": []} for root, _, files in os.walk(data_dir): for file in files: file_path = os.path.join(root, file) with open(file_path, "r", encoding="utf-8") as f: content = f.read() data["file_path"].append(file_path) data["content"].append(content) return data # Load data data = read_files_recursively(data_dir) # Create dataset dataset = Dataset.from_dict(data) # Print a preview of the dataset print(dataset) # Log in to Hugging Face # os.system("huggingface-cli login") # Upload the dataset to the Hugging Face Hub dataset.push_to_hub(dataset_name)
./openacc-vv/parallel_loop_reduction_bitxor_loop.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,reduction,combined-constructs,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int * a = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int * b = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int * b_copy = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int * c = (unsigned int *)malloc(10 * sizeof(unsigned int)); unsigned int temp = 0; for (int x = 0; x < 10*n; ++x){ b[x] = (unsigned int) rand() / (real_t)(RAND_MAX / 1000); b_copy[x] = b[x]; a[x] = (unsigned int) rand() / (real_t)(RAND_MAX / 1000); } for (int x = 0; x < 10; ++x){ c[x] = 0; } #pragma acc data copyin(a[0:10*n]) copy(b[0:10*n], c[0:10]) { #pragma acc parallel loop gang private(temp) for (int x = 0; x < 10; ++x){ temp = 0; #pragma acc loop worker reduction(^:temp) for (int y = 0; y < n; ++y){ temp = temp ^ a[x * n + y]; } c[x] = temp; #pragma acc loop worker for (int y = 0; y < n; ++y){ b[x * n + y] = b[x * n + y] + c[x]; } } } for (int x = 0; x < 10; ++x){ temp = 0; for (int y = 0; y < n; ++y){ temp = temp ^ a[x * n + y]; } if (temp != c[x]){ err += 1; } for (int y = 0; y < n; ++y){ if (b[x * n + y] != b_copy[x * n + y] + c[x]){ err += 1; } } } return err; } #endif #ifndef T2 //T2:parallel,private,reduction,combined-constructs,loop,nonvalidating,V:2.7-2.7 int test2(){ int err = 0; srand(SEED); unsigned int * a = (unsigned int *)malloc(25 * n * sizeof(unsigned int)); unsigned int * b = (unsigned int *)malloc(25 * n * sizeof(unsigned int)); unsigned int * b_copy = (unsigned int *)malloc(25 * n * sizeof(unsigned int)); unsigned int * c = (unsigned int *)malloc(25 * sizeof(unsigned int)); unsigned int temp[5]; for (int x = 0; x < n; ++x){ a[x] = (unsigned int) rand() / (real_t)(RAND_MAX / 1000); b[x] = (unsigned int) rand() / (real_t)(RAND_MAX / 1000); b_copy[x] = b[x]; } for (int x = 0; x < 25; ++x) { c[x] = 0; } for (int x = 0; x < 5; ++x) { temp[x] = 0; } #pragma acc data copyin(a[0:25*n]) copy(b[0:25*n], c[0:25]) { #pragma acc parallel loop gang private(temp) for (int x = 0; x < 5; ++x) { for (int y = 0; y < 5; ++y) { temp[y] = 0; } #pragma acc loop worker reduction(^:temp) for (int y = 0; y < 5 * n; ++y) { temp[y % 5] = temp[y % 5] ^ a[x * 5 * n + y]; } for (int y = 0; y < 5; ++y) { c[x * 5 + y] = temp[y]; } #pragma acc loop worker for (int y = 0; y < 5 * n; ++y) { b[x * 5 * n + y] = b[x * 5 * n + y] + c[x * 5 + (y % 5)]; } } } for (int x = 0; x < 5; ++x) { for (int y = 0; y < 5; ++y) { temp[y] = 0; } for (int y = 0; y < 5 * n; ++y) { temp[y % 5] = temp[y % 5] ^ a[x * 5 * n + y]; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif return failcode; }
./openacc-vv/atomic_bitand_equals.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int *a = new int[n]; int *totals = new int[(n/10 + 1)]; int *totals_comparison = new int[(n/10 + 1)]; for (int x = 0; x < n; ++x){ for (int y = 0; y < 8; ++y){ if (rand()/(real_t)(RAND_MAX) < .933){ //.933 gets close to a 50/50 distribution for a collescence of 10 values a[x] += 1<<y; } } } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 0; totals_comparison[x] = 0; for (int y = 0; y < 8; ++y){ totals[x] += 1<<y; totals_comparison[x] += 1<<y; } } #pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic totals[x%(n/10 + 1)] &= a[x]; } } } for (int x = 0; x < n; ++x){ totals_comparison[x%(n/10 + 1)] &= a[x]; } for (int x = 0; x < 10; ++x){ if (fabs(totals_comparison[x] - totals[x]) > PRECISION){ err += 1; break; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/data_wait.c
#include "acc_testsuite.h" #ifndef T1 //T1:async,data,wait,V:3.2-3.3 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); real_t * c = (real_t *)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; } #pragma acc data copy(a[0:n], b[0:n], c[0:n]) async(0) { #pragma acc parallel loop async(1) wait(0) for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } #pragma acc wait(1) async(0) } #pragma acc data copy(a[0:n], b[0:n], c[0:n]) wait(0) { #pragma acc parallel loop for (int x = 0; x < n; ++x){ c[x] += c[x]; } } for (int x = 0; x < n; ++x){ if (fabs(c[x] - (2 * (a[x] + b[x]))) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_update_expr_or_x_end.F90
#ifndef T1 !T1:construct-independent,atomic,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators REAL(8),DIMENSION(LOOPCOUNT, 10):: randoms LOGICAL,DIMENSION(LOOPCOUNT, 10):: a !Data LOGICAL,DIMENSION(LOOPCOUNT):: totals, totals_comparison INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) DO x = 1, LOOPCOUNT DO y = 1, 10 IF (randoms(x, y) > .933) THEN a(x, y) = .TRUE. ELSE a(x, y) = .FALSE. END IF END DO END DO totals = .FALSE. totals_comparison = .FALSE. !$acc data copyin(a(1:LOOPCOUNT,1:10)) copy(totals(1:LOOPCOUNT)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT DO y = 1, 10 !$acc atomic update totals(x) = a(x, y) .OR. totals(x) !$acc end atomic END DO END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT DO y = 1, 10 totals_comparison(x) = totals_comparison(x) .OR. a(x, y) END DO END DO DO x = 1, LOOPCOUNT IF (totals_comparison(x) .NEQV. totals(x)) THEN errors = errors + 1 WRITE(*, *) totals_comparison(x) END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/declare_function_scope_create.cpp
#include "acc_testsuite.h" void create_test(real_t *a, real_t *b, real_t *c, real_t *d){ #pragma acc declare create(c[0:n]) #pragma acc parallel present(a[0:n], b[0:n], d[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } #pragma acc loop for (int x = 0; x < n; ++x){ d[x] = c[x] * a[x]; } } } void create_as_present(real_t *a, real_t *b, real_t *c, real_t *d){ #pragma acc declare create(c[0:n]) #pragma acc parallel present(a[0:n], b[0:n], d[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = c[x] + a[x] + b[x]; } #pragma acc loop for (int x = 0; x < n; ++x){ d[x] = c[x] * a[x]; } } } #ifndef T1 //T1:declare,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t ** a = (real_t **)malloc(n * sizeof(real_t)); real_t ** b = (real_t **)malloc(n * sizeof(real_t)); real_t ** c = (real_t **)malloc(n * sizeof(real_t)); real_t ** d = (real_t **)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = new real_t[n]; b[x] = new real_t[n]; c[x] = new real_t[n]; d[x] = new real_t[n]; for (int y = 0; y < n; ++y){ a[x][y] = rand() / (real_t)(RAND_MAX / 10); b[x][y] = rand() / (real_t)(RAND_MAX / 10); c[x][y] = 1; d[x][y] = 0; } } #pragma acc data copyin(a[0:n][0:n], b[0:n][0:n]) copyout(d[0:n][0:n]) { for (int x = 0; x < n; ++x){ create_test(a[x], b[x], c[x], d[x]); } } for (int x = 0; x < n; ++x){ for (int y = 0; y < n; ++y){ if (fabs(d[x][y] - (a[x][y] * (a[x][y] + b[x][y]))) > PRECISION){ err += 1; } } } return err; } #endif #ifndef T2 //T2:declare,construct-independent,V:2.0-2.7 int test2(){ int err = 0; srand(SEED); real_t ** a = (real_t **)malloc(n * sizeof(real_t)); real_t ** b = (real_t **)malloc(n * sizeof(real_t)); real_t ** c = (real_t **)malloc(n * sizeof(real_t)); real_t ** d = (real_t **)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ for (int y = 0; y < n; ++y){ a[x][y] = rand() / (real_t)(RAND_MAX / 10); b[x][y] = rand() / (real_t)(RAND_MAX / 10); c[x][y] = 2; d[x][y] = 0; } } #pragma acc data copyin(a[0:n][0:n], b[0:n][0:n]) copy(c[0:n][0:n]) copyout(d[0:n][0:n]) { for (int x = 0; x < n; ++x){ create_as_present(a[x], b[x], c[x], d[x]); } } for (int x = 0; x < n; ++x){ for (int y = 0; y < n; ++y){ if (fabs(c[x][y] - (2 + a[x][y] + b[x][y])) > PRECISION){ err += 1; } if (fabs(d[x][y] - (a[x][y] * c[x][y])) > PRECISION * 2){ err += 1; } } } return err; } #endif #ifndef T3 //T3:declare,construct-independent,devonly,V:2.0-2.7 int test3(){ int err = 0; srand(SEED); real_t ** a = (real_t **)malloc(n * sizeof(real_t)); real_t ** b = (real_t **)malloc(n * sizeof(real_t)); real_t ** c = (real_t **)malloc(n * sizeof(real_t)); real_t ** d = (real_t **)malloc(n * sizeof(real_t)); int *devtest = (int *)malloc(sizeof(int)); devtest[0] = 1; #pragma acc enter data copyin(devtest[0:1]) #pragma acc parallel present(devtest[0:1]) { devtest[0] = 0; } if (devtest[0] == 1){ for (int x = 0; x < n; ++x){ for (int y = 0; y < n; ++y){ a[x][y] = rand() / (real_t)(RAND_MAX / 10); b[x][y] = rand() / (real_t)(RAND_MAX / 10); c[x][y] = 3; } } #pragma acc data copyin(a[0:n][0:n], b[0:n][0:n]) { for (int x = 0; x < n; ++x){ #pragma acc data copyin(c[x:1][0:n]) copyout(d[x:1][0:n]) { create_as_present(a[x], b[x], c[x], d[x]); } for (int y = 0; y < n; ++y){ if (fabs(c[x][y] - 3) > PRECISION){ err += 1; } } for (int y = 0; y < n; ++y){ if (fabs(d[x][y] - (a[x][y] * (3 + a[x][y] + b[x][y]))) > PRECISION * 2){ err += 1; } } } } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif return failcode; }
./openacc-vv/serial_async.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:serial,async,wait,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; real_t * d = new real_t[n]; real_t * e = new real_t[n]; real_t * f = new real_t[n]; real_t * g = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; d[x] = rand() / (real_t)(RAND_MAX / 10); e[x] = rand() / (real_t)(RAND_MAX / 10); f[x] = 0.0; g[x] = 0.0; } #pragma acc data copyin(a[0:n], b[0:n], d[0:n], e[0:n], c[0:n], f[0:n], g[0:n]) { #pragma acc serial async(1) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } #pragma acc serial async(2) { #pragma acc loop for (int x = 0; x < n; ++x){ f[x] = d[x] + e[x]; } } #pragma acc serial wait(1, 2) async(3) { #pragma acc loop for (int x = 0; x < n; ++x){ g[x] = c[x] + f[x]; } } #pragma acc update host(c[0:n]) async(1) #pragma acc update host(f[0:n]) async(2) #pragma acc update host(g[0:n]) async(3) #pragma acc wait(1) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } #pragma acc wait(2) for (int x = 0; x < n; ++x){ if (fabs(f[x] - (d[x] + e[x])) > PRECISION){ err += 1; } } #pragma acc wait(3) for (int x = 0; x < n; ++x){ if (fabs(g[x] - (a[x] + b[x] + d[x] + e[x])) > PRECISION){ err += 1; } } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/serial_loop_reduction_bitor_loop.F90
#ifndef T1 !T1:serial,private,reduction,combined-constructs,loop,V:2.6-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER:: errors, x, y, z, temp INTEGER,DIMENSION(LOOPCOUNT, 10):: a, b, b_copy INTEGER,DIMENSION(10):: c REAL(8):: false_margin REAL(8),DIMENSION(LOOPCOUNT, 10, 17):: randoms errors = 0 false_margin = exp(log(.5) / LOOPCOUNT) SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) DO x = 1, LOOPCOUNT DO y = 1, 10 b(x, y) = INT(randoms(x, y, 17) * 1000) DO z = 1, 16 IF (randoms(x, y, z) .gt. false_margin) THEN a(x, y) = a(x, y) + 2**(z-1) END IF END DO END DO END DO b_copy = b !$acc data copyin(a(1:LOOPCOUNT, 1:10)) copy(b(1:LOOPCOUNT, 1:10), c(1:10)) !$acc serial loop gang private(temp) DO y = 1, 10 temp = 0 !$acc loop worker reduction(ior:temp) DO x = 1, LOOPCOUNT temp = ior(temp, a(x, y)) END DO c(y) = temp !$acc loop worker DO x = 1, LOOPCOUNT b(x, y) = b(x, y) + c(y) END DO END DO !$acc end data DO y = 1, 10 temp = a(1, y) DO x = 2, LOOPCOUNT temp = ior(temp, a(x, y)) END DO IF (temp .ne. c(y)) THEN errors = errors + 1 END IF DO x = 1, LOOPCOUNT IF (b(x, y) .ne. (b_copy(x, y) + temp)) THEN errors = errors + 1 END IF END DO END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/parallel_default_copy.F90
#ifndef T1 !T1:devonly,parallel,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c !Data INTEGER :: errors = 0 LOGICAL,DIMENSION(1):: devtest devtest(1) = .TRUE. !$acc enter data copyin(devtest(1:1)) !$acc parallel devtest(1) = .FALSE. !$acc end parallel !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 0 !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT c(x) = c(x) + a(x) + b(x) END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT IF (abs(c(x) - (a(x) + b(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif #ifndef T2 !T2:devonly,parallel,V:2.0-2.7 LOGICAL FUNCTION test2() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c !Data INTEGER :: errors = 0 LOGICAL,DIMENSION(1):: devtest devtest(1) = .TRUE. !$acc enter data copyin(devtest(1:1)) !$acc parallel devtest(1) = .FALSE. !$acc end parallel !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) IF (devtest(1)) THEN CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 1 !$acc enter data copyin(c(1:LOOPCOUNT)) c = 0 !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT c(x) = c(x) + a(x) + b(x) END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT IF (abs(c(x)) .gt. PRECISION) THEN errors = errors + 1 END IF END DO !$acc exit data copyout(c(1:LOOPCOUNT)) DO x = 1, LOOPCOUNT IF (abs(c(x) - (a(x) + b(x) + 1)) .gt. PRECISION) THEN errors = errors + 1 END IF END DO END IF IF (errors .eq. 0) THEN test2 = .FALSE. ELSE test2 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif #ifndef T2 LOGICAL :: test2 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif #ifndef T2 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test2() END DO IF (failed) THEN failcode = failcode + 2 ** 1 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/atomic_structured_x_bitor_expr_assign.c
#include "acc_testsuite.h" bool is_possible(int* a, int* b, int length, int prev){ if (length == 0){ return true; } int *passed_a = (int *)malloc((length - 1) * sizeof(int)); int *passed_b = (int *)malloc((length - 1) * sizeof(int)); for (int x = 0; x < length; ++x){ if (b[x] == (prev | a[x])){ for (int y = 0; y < x; ++y){ passed_a[y] = a[y]; passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ passed_a[y - 1] = a[y]; passed_b[y - 1] = b[y]; } if (is_possible(passed_a, passed_b, length - 1, b[x])){ free(passed_a); free(passed_b); return true; } } } free(passed_a); free(passed_b); return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int *a = (int *)malloc(n * sizeof(int)); int *b = (int *)malloc(n * sizeof(int)); int *totals = (int *)malloc((n/10 + 1) * sizeof(int)); int *totals_comparison = (int *)malloc((n/10 + 1) * sizeof(int)); int *temp_a = (int *)malloc(10 * sizeof(int)); int *temp_b = (int *)malloc(10 * sizeof(int)); int temp_iterator; int ab_iterator; for (int x = 0; x < n; ++x){ for (int y = 0; y < 8; ++y){ if (rand()/(real_t)(RAND_MAX) < .933){ //.933 gets close to a 50/50 distribution for a collescence of 10 values a[x] += 1<<y; } } } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 0; totals_comparison[x] = 0; for (int y = 0; y < 8; ++y){ totals[x] += 1<<y; totals_comparison[x] += 1<<y; } } for (int x = 0; x < n; ++x){ b[x] = 0; } #pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) copyout(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic capture { totals[x/10] = totals[x/10] | a[x]; b[x] = totals[x/10]; } } } } for (int x = 0; x < n; ++x){ totals_comparison[x/10] |= a[x]; } for (int x = 0; x < (n/10 + 1); ++x){ if (totals_comparison[x] != totals[x]){ err += 1; break; } } for (int x = 0; x < n; x = x + 10){ temp_iterator = 0; for (ab_iterator = x; ab_iterator < n && ab_iterator < x + 10; ab_iterator+= 1){ temp_a[temp_iterator] = a[ab_iterator]; temp_b[temp_iterator] = b[ab_iterator]; } if (!is_possible(temp_a, temp_b, temp_iterator, 1)){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_update_expr_bitxor_x.c
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int *a = (int *)malloc(n * sizeof(int)); int *totals = (int *)malloc((n/10 + 1) * sizeof(int)); int *totals_comparison = (int *)malloc((n/10 + 1) * sizeof(int)); for (int x = 0; x < n; ++x){ for (int y = 0; y < 8; ++y){ if (rand()/(real_t)(RAND_MAX) > .5){ a[x] += 1<<y; } } } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 0; totals_comparison[x] = 0; } #pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic update totals[x%(n/10 + 1)] = a[x] ^ totals[x%(n/10 + 1)]; } } } for (int x = 0; x < n; ++x){ totals_comparison[x%(n/10 + 1)] ^= a[x]; } for (int x = 0; x < 10; ++x){ if (fabs(totals_comparison[x] - totals[x]) > PRECISION){ err += 1; break; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_preincrement.c
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t *a = (real_t *)malloc(n * sizeof(real_t)); real_t *b = (real_t *)malloc(n * sizeof(real_t)); int *distribution = (int *)malloc(10 * sizeof(int)); int *distribution_comparison = (int *)malloc(10 * sizeof(int)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } for (int x = 0; x < 10; ++x){ distribution[x] = 0; distribution_comparison[x] = 0; } #pragma acc data copyin(a[0:n], b[0:n]) copy(distribution[0:10]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop for (int y = 0; y < n; ++y){ #pragma acc atomic ++distribution[(int) (a[x]*b[y]/10)]; } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < n; ++y){ distribution_comparison[(int) (a[x]*b[y]/10)]++; } } for (int x = 0; x < 10; ++x){ if (distribution_comparison[x] != distribution[x]){ err += 1; break; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_switch.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,syntactic,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int * a = new int[n]; real_t * b = new real_t[n]; real_t * b_host = new real_t[n]; real_t * c = new real_t[n]; real_t tempc = 0.0; for (int x = 0; x < n; ++x){ a[x] = floor(rand() / (real_t)(RAND_MAX / 10)); b[x] = rand() / (real_t)(RAND_MAX / 10); b_host[x] = b[x]; c[x] = 0.0; } #pragma acc enter data copyin(a[0:n], b[0:n], c[0:n]) #pragma acc parallel present(a[0:n], b[0:n], c[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ switch(a[x]){ case 0: c[x] = b[x] * b[x]; break; case 1: c[x] = b[x] / b[x]; break; case 2: b[x] = b[x] / 2; default: c[x] = a[x] + b[x]; } } } #pragma acc exit data delete(a[0:n], b[0:n]) copyout(c[0:n]) for (int x = 0; x < n; ++x){ switch(a[x]){ case 0: tempc = b_host[x] * b_host[x]; break; case 1: tempc = b_host[x] / b_host[x]; break; case 2: b_host[x] = b_host[x] / 2; default: tempc = a[x] + b_host[x]; } if (fabs(c[x] - tempc) > PRECISION){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_capture_assign_min_expr_list_x.F90
RECURSIVE FUNCTION IS_POSSIBLE(a, b, c, length, init) RESULT(POSSIBLE) INTEGER, INTENT(IN) :: length REAL(8), INTENT(IN) :: init REAL(8),DIMENSION(length), INTENT(IN) :: a REAL(8),DIMENSION(length), INTENT(IN) :: b REAL(8),DIMENSION(length), INTENT(IN) :: c REAL(8),DIMENSION(length - 1) :: passed_a REAL(8),DIMENSION(length - 1) :: passed_b REAL(8),DIMENSION(length - 1) :: passed_c REAL(8) :: holder LOGICAL :: POSSIBLE INTEGER :: x, y IF (length .eq. 0) THEN POSSIBLE = .TRUE. RETURN END IF POSSIBLE = .FALSE. DO x = 1, length IF (abs(c(x) - init) .gt. (10 - length) * PRECISION) THEN DO y = 1, x - 1 passed_a(y) = a(y) passed_b(y) = b(y) END DO DO y = x + 1, length passed_a(y - 1) = a(y) passed_b(y - 1) = b(y) END DO holder = min(a(x), b(x), init) IF (IS_POSSIBLE(passed_a, passed_b, passed_c, length - 1, holder)) THEN POSSIBLE = .TRUE. RETURN END IF END IF END DO END FUNCTION IS_POSSIBLE #ifndef T1 !T1:construct-independent,atomic,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators REAL(8),DIMENSION(LOOPCOUNT, 10):: a, b, c !Data REAL(8),DIMENSION(LOOPCOUNT):: totals, totals_comparison REAL(8),DIMENSION(10):: passed_a, passed_b, passed_c REAL(8):: init LOGICAL IS_POSSIBLE INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) totals = 0 totals_comparison = 0 !$acc data copyin(a(1:LOOPCOUNT, 1:10), b(1:LOOPCOUNT, 1:10)) copy(totals(1:LOOPCOUNT)) copyout(c(1:LOOPCOUNT, 1:10)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT DO y = 1, 10 !$acc atomic capture c(x, y) = totals(x) totals(x) = min(a(x, y), b(x, y), totals(x)) !$acc end atomic END DO END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT DO y = 1, 10 totals_comparison(x) = min(totals_comparison(x), a(x, y), b(x, y)) END DO END DO DO x = 1, LOOPCOUNT IF (totals_comparison(x) .NE. totals(x)) THEN errors = errors + 1 WRITE(*, *) totals_comparison(x) END IF END DO DO x = 1, LOOPCOUNT DO y = 1, 10 passed_a(y) = a(x, y) passed_b(y) = b(x, y) passed_c(y) = c(x, y) END DO init = 0 IF (IS_POSSIBLE(passed_a, passed_b, passed_c, 10, init) .eqv. .FALSE.) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/set_device_type_num_nvidia.F90
#ifndef T1 !T1:runtime,construct-independent,internal-control-values,set,nonvalidating,V:2.5-2.7 LOGICAL FUNCTION test1() USE OPENACC IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: device_num INTEGER :: device_type INTEGER :: errors = 0 device_type = acc_get_device_type() device_num = acc_get_device_num(device_type) !$acc set device_type(nvidia) device_num(device_num) IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/shutdown_device_type.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:shutdown,runtime,syntactic,V:2.5-3.2 int test1(){ int err = 0; #pragma acc shutdown device_type(host) return err; } #endif #ifndef T2 //T2:shutdown,runtime,syntactic,V:2.5-3.2 int test2(){ int err = 0; #pragma acc shutdown device_type(multicore) return err; } #endif #ifndef T3 //T3:shutdown,runtime,syntactic,V:2.5-3.2 int test3(){ int err = 0; #pragma acc shutdown device_type(default) return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif return failcode; }
./openacc-vv/acc_memcpy_to_device.c
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test1(){ int err = 0; real_t *a = (real_t *)malloc(n * sizeof(real_t)); real_t *b = (real_t *)malloc(n * sizeof(real_t)); real_t *c = (real_t *)malloc(n * sizeof(real_t)); real_t *hostdata = (real_t *)malloc(3 * n * sizeof(real_t)); real_t *devdata; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 1; } devdata = acc_create(hostdata, 3 * n * sizeof(real_t)); acc_memcpy_to_device(devdata, a, n * sizeof(real_t)); acc_memcpy_to_device(&(devdata[n]), b, n * sizeof(real_t)); acc_memcpy_to_device(&(devdata[2*n]), c, n * sizeof(real_t)); #pragma acc data deviceptr(devdata) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ devdata[2*n + x] += devdata[x] + devdata[n + x]; } } } #pragma acc exit data copyout(hostdata[0:3*n]) for (int x = 0; x < n; ++x){ if (fabs(hostdata[2 * n + x] - (1 + hostdata[n + x] + hostdata[x])) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_loop_reduction_or_vector_loop.c
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,reduction,combined-constructs,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); char * a = (char *)malloc(10 * n * sizeof(char)); char * b = (char *)malloc(10 * sizeof(char)); real_t false_margin = pow(exp(1), log(.5)/n); char temp = 0; char found; for (int x = 0; x < 10 * n; ++x){ if(rand() / (real_t)(RAND_MAX) > false_margin){ a[x] = 1; } else{ a[x] = 0; } } #pragma acc data copyin(a[0:10*n]) copy(b[0:10]) { #pragma acc parallel loop private(temp) for (int x = 0; x < 10; ++x){ temp = 0; #pragma acc loop vector reduction(||:temp) for (int y = 0; y < n; ++y){ temp = temp || a[x * n + y]; } b[x] = temp; } } for (int x = 0; x < 10; ++x){ found = 0; for (int y = 0; y < n; ++y){ if (a[x * n + y] &! 0){ found = 1; } } if (found != b[x]){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/kernels_loop_seq.F90
#ifndef T1 !T1:kernels,combined-constructs,loop,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b !Data INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) b = 0 !$acc data copyin(a(1:LOOPCOUNT)) copy(b(1:LOOPCOUNT)) !$acc kernels loop seq DO x = 2, LOOPCOUNT b(x) = b(x - 1) + a(x) END DO !$acc end data DO x = 2, LOOPCOUNT IF (abs(b(x) - (b(x - 1) + a(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/acc_create.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; } acc_create(c, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel present(c[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } } acc_copyout(c, n * sizeof(real_t)); for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } return err; } #endif #ifndef T2 //T2:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; } acc_create(c, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel present(c[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } } #pragma acc exit data copyout(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } return err; } #endif #ifndef T3 //T3:runtime,data,executable-data,compatibility-features,construct-independent,V:2.0-2.7 int test3(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; } acc_pcreate(c, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) present(c[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } } #pragma acc exit data copyout(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } return err; } #endif #ifndef T4 //T4:runtime,data,executable-data,compatibility-features,construct-independent,V:2.0-2.7 int test4(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; } acc_present_or_create(c, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) present(c[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } } #pragma acc exit data copyout(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } return err; } #endif #ifndef T5 //T5:runtime,data,executable-data,devonly,construct-independent,reference-counting,V:2.5-2.7 int test5(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; int * dev_test = (int *)malloc(sizeof(int)); dev_test[0] = 1; #pragma acc enter data copyin(dev_test[0:1]) #pragma acc parallel present(dev_test[0:1]) { dev_test[0] = 0; } if (dev_test[0] == 1){ for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 1; } #pragma acc enter data copyin(c[0:n]) for (int x = 0; x < n; ++x){ c[x] = 0; } acc_create(c, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel present(c[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x) { c[x] += a[x] + b[x]; } } } #pragma acc exit data copyout(c[0:n]) for (int x = 0; x < n; ++x) { if (fabs(c[x] - (1 + a[x] + b[x])) > PRECISION) { err += 1; } } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif #ifndef T4 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test4(); } if (failed != 0){ failcode = failcode + (1 << 3); } #endif #ifndef T5 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test5(); } if (failed != 0){ failcode = failcode + (1 << 4); } #endif return failcode; }
./openacc-vv/parallel_loop_gang.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,combined-constructs,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; } #pragma acc data copyin(a[0:n], b[0:n]) copy(c[0:n]) { #pragma acc parallel loop gang for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/acc_copyout_finalize_with_len.F90
#ifndef T1 !T1:runtime,data,executable-data,construct-independent,V:2.5-2.7 LOGICAL FUNCTION test1() USE OPENACC IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c !Data REAL(8) :: RAND INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 0 !$acc enter data create(c(1:LOOPCOUNT)) !$acc enter data create(c(1:LOOPCOUNT)) !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) present(c(1:LOOPCOUNT)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT c(x) = a(x) + b(x) END DO !$acc end parallel !$acc end data CALL acc_copyout_finalize(c(1), LOOPCOUNT*8) DO x = 1, LOOPCOUNT IF (abs(c(x) - (a(x) + b(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" !Conditionally define test functions #ifndef T1 LOGICAL :: test1 #endif failcode = 0 failed = .FALSE. #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/parallel_loop_reduction_multiply_general.F90
#ifndef T1 !T1:parallel,reduction,combined-constructs,loop,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b !Data INTEGER :: errors = 0 REAL(8) :: temp = 1 REAL(8) :: multiplied_total = 1 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) a = (999.4 + a)/1000 b = (999.4 + b)/1000 !$acc data copyin(a(1:LOOPCOUNT)) !$acc parallel loop reduction(*:multiplied_total) DO x = 1, LOOPCOUNT multiplied_total = multiplied_total * (a(x) + b(x)) END DO !$acc end data DO x = 1, LOOPCOUNT temp = temp * (a(x) + b(x)) END DO IF (abs(temp - multiplied_total) .gt. ((temp / 2) + (multiplied_total / 2)) * PRECISION) THEN WRITE(*, *) temp WRITE(*, *) multiplied_total errors = errors + 1 END IF IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/serial_if.c
#include "acc_testsuite.h" #ifndef T1 //T1:serial,if,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); real_t * c = (real_t *)malloc(n * sizeof(real_t)); int accel = 1; int host = 0; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; } #pragma acc serial if(host) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err = 1; } } return err; } #endif #ifndef T2 //T2:serial,if,devonly,V:2.6-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); real_t * c = (real_t *)malloc(n * sizeof(real_t)); int accel = 1; int host = 0; int * devtest = (int *)malloc(sizeof(int)); devtest[0] = 1; #pragma acc data copyin(devtest[0:1]) #pragma acc parallel present(devtest[0:1]) { devtest[0] = 0; } if (devtest[0] == 1){ for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; } #pragma acc enter data copyin(a[0:n], b[0:n], c[0:n]) #pragma acc serial if(host) present(a[0:n], b[0:n], c[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] += a[x] + b[x]; } } #pragma acc exit data delete(a[0:n], b[0:n]) copyout(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x]) > PRECISION){ err = 1; } } } return err; } #endif #ifndef T3 //T3:serial,if,V:2.6-2.7 int test3(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); real_t * c = (real_t *)malloc(n * sizeof(real_t)); int accel = 1; int host = 0; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; } #pragma acc enter data copyin(a[0:n], b[0:n], c[0:n]) #pragma acc serial if(accel) present(a[0:n], b[0:n], c[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] += a[x] + b[x]; } } #pragma acc exit data delete(a[0:n], b[0:n]) copyout(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION * 2){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif return failcode; }
./openacc-vv/atomic_structured_assign_x_lshift_expr.c
#include "acc_testsuite.h" bool is_possible(unsigned int a, unsigned int* b, int length, unsigned int prev){ if (length == 0){ return true; } unsigned int passed_a = 0; unsigned int *passed_b = (unsigned int *)malloc((length - 1) * sizeof(unsigned int)); for (int x = 0; x < length; ++x){ if (b[x] == prev){ for (int y = 0; y < x; ++y){ if ((a>>y)%2 == 1){ passed_a += 1<<y; } passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ if ((a>>y) % 2 == 1){ passed_a += 1<<(y - 1); } passed_b[y - 1] = b[y]; } if ((a>>x)%2 == 1){ if (is_possible(passed_a, passed_b, length - 1, prev << 1)){ return true; } } else { if (is_possible(passed_a, passed_b, length - 1, prev)){ return true; } } } } free(passed_b); return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int *a = (unsigned int *)malloc(n * sizeof(int)); unsigned int *b = (unsigned int *)malloc(n * sizeof(int)); unsigned int *c = (unsigned int *)malloc(7 * n * sizeof(int)); unsigned int passed = 1; for (int x = 0; x < n; ++x){ a[x] = 1; for (int y = 0; y < 7; ++y){ if ((rand()/(real_t) (RAND_MAX)) > .5){ b[x] += 1<<y; } } } #pragma acc data copyin(b[0:n]) copy(a[0:n]) copyout(c[0:7*n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop for (int y = 0; y < 7; ++y){ c[x * 7 + y] = a[x]; if ((b[x]>>y)%2 == 1){ #pragma acc atomic capture { c[x * 7 + y] = a[x]; a[x] = a[x] << 1; } } } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < 7; ++y){ if ((b[x]>>y)%2 == 1){ a[x] >>= 1; } } if (a[x] != 1){ err += 1; } } for (int x = 0; x < n; ++x){ if (!is_possible(b[x], &(c[x * 7]), 7, passed)){ err++; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_loop_auto.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,combined-constructs,V:2.0-2.7 //data dependent, treated with as a seq clause. Added the num_gangs clause with 1 int test1(){ int err = 0; srand(SEED); real_t * device = new real_t[n]; real_t * host = new real_t[n]; 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_length(1) num_workers(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; } } delete[] device; delete[] host; return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed += test1(); } if (failed){ failcode += (1 << 2); } #endif return failcode; }
./openacc-vv/kernels_num_gangs.c
#include "acc_testsuite.h" #ifndef T1 //T1:kernels,loop,V:2.5-2.7 int test1(){ int err = 0; srand(SEED); real_t * restrict a = (real_t *)malloc(n * sizeof(real_t)); real_t * restrict b = (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; } #pragma acc data copyin(a[0:n]) copyout(b[0:n]) { #pragma acc kernels loop num_gangs(16) for (int x = 0; x < n; ++x){ b[x] = a[x]; } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_loop_independent.c
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,combined-constructs,V:2.7-3.2 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copy(a[0:n]) copyout(b[0:n]) { #pragma acc parallel loop independent for (int x = 0; x < n; ++x){ b[x] = a[x]; } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/serial_loop_reduction_multiply_vector_loop.c
#include "acc_testsuite.h" #ifndef T1 //T1:serial,loop,reduction,combined-constructs,V:2.6-2.7 int test1(){ int err = 0; int multiplicitive_n = 128; srand(SEED); real_t * a = (real_t *)malloc(10 * multiplicitive_n * sizeof(real_t)); real_t * b = (real_t *)malloc(10 * multiplicitive_n * sizeof(real_t)); real_t * c = (real_t *)malloc(10 * sizeof(real_t)); real_t temp; for (int x = 0; x < 10 * multiplicitive_n; ++x){ a[x] = rand() / (real_t) RAND_MAX; b[x] = rand() / (real_t) RAND_MAX; } #pragma acc data copyin(a[0:10*multiplicitive_n], b[0:10*multiplicitive_n]) copyout(c[0:10]) { #pragma acc serial loop private(temp) for (int x = 0; x < 10; ++x){ temp = 1.0; #pragma acc loop vector reduction(*:temp) for (int y = 0; y < multiplicitive_n; ++y){ temp *= a[(x * multiplicitive_n) + y] + b[(x * multiplicitive_n) + y]; } c[x] = temp; } } for (int x = 0; x < 10; ++x){ for (int y = 0; y < multiplicitive_n; ++y){ c[x] /= a[(x * multiplicitive_n) + y] + b[(x * multiplicitive_n) + y]; } } for (int x = 0; x < 10; ++x){ if (fabs(c[x] - 1) > PRECISION * (4 * multiplicitive_n - 1)){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_structured_assign_rshift_equals.cpp
#include "acc_testsuite.h" bool is_possible(unsigned int a, unsigned int* b, int length, unsigned int prev){ if (length == 0){ return true; } unsigned int passed_a = 0; unsigned int *passed_b = (unsigned int *)malloc((length - 1) * sizeof(unsigned int)); for (int x = 0; x < length; ++x){ if (b[x] == prev){ for (int y = 0; y < x; ++y){ if ((a>>y)%2 == 1){ passed_a += 1<<y; } passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ if ((a>>y) % 2 == 1){ passed_a += 1<<(y - 1); } passed_b[y - 1] = b[y]; } if ((a >> x) % 2 == 1){ if (is_possible(passed_a, passed_b, length - 1,prev >> 1)){ delete[] passed_b; return true; } } else{ if (is_possible(passed_a, passed_b, length - 1, prev)){ delete[] passed_b; return true; } } } } delete[] passed_b; return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int *a = (unsigned int *)malloc(n * sizeof(int)); unsigned int *b = (unsigned int *)malloc(n * sizeof(int)); unsigned int *c = (unsigned int *)malloc(7 * n * sizeof(int)); unsigned int passed = 1<<8; for (int x = 0; x < n; ++x){ a[x] = 1<<8; for (int y = 0; y < 7; ++y){ if ((rand()/(real_t) (RAND_MAX)) > .5){ b[x] += 1<<y; } } } #pragma acc data copyin(b[0:n]) copy(a[0:n]) copyout(c[0:7*n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop for (int y = 0; y < 7; ++y){ c[x * 7 + y] = a[x]; if ((b[x]>>y)%2 == 1){ #pragma acc atomic capture { c[x * 7 + y] = a[x]; a[x] >>= 1; } } } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < 7; ++y){ if ((b[x]>>y)%2 == 1){ a[x] <<= 1; } } if (a[x] != 1<<8){ err += 1; } } for (int x = 0; x < n; ++x){ if (!is_possible(b[x], &(c[x * 7]), 7, passed)){ err++; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_structured_assign_expr_bitand_x.c
#include "acc_testsuite.h" bool is_possible(int* a, int* b, int length, int prev){ if (length == 0){ return true; } int *passed_a = (int *)malloc((length - 1) * sizeof(int)); int *passed_b = (int *)malloc((length - 1) * sizeof(int)); for (int x = 0; x < length; ++x){ if (b[x] == prev){ for (int y = 0; y < x; ++y){ passed_a[y] = a[y]; passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ passed_a[y - 1] = a[y]; passed_b[y - 1] = b[y]; } if (is_possible(passed_a, passed_b, length - 1, prev & a[x])){ free(passed_a); free(passed_b); return true; } } } free(passed_a); free(passed_b); return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int *a = (int *)malloc(n * sizeof(int)); int *b = (int *)malloc(n * sizeof(int)); int *totals = (int *)malloc((n/10 + 1) * sizeof(int)); int *totals_comparison = (int *)malloc((n/10 + 1) * sizeof(int)); int *temp_a = (int *)malloc(10 * sizeof(int)); int *temp_b = (int *)malloc(10 * sizeof(int)); int temp_iterator; int ab_iterator; for (int x = 0; x < n; ++x){ for (int y = 0; y < 8; ++y){ if (rand()/(real_t)(RAND_MAX) < .933){ //.933 gets close to a 50/50 distribution for a collescence of 10 values a[x] += 1<<y; } } } for (int x = 0; x < n/10 + 1; ++x){ for (int y = 0; y < 8; ++y){ totals[x] = 1<<y; totals_comparison[x] = 1<<y; } } for (int x = 0; x < n; ++x){ b[x] = 0; } #pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) copyout(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic capture { b[x] = totals[x/10]; totals[x/10] = a[x] & totals[x/10]; } } } } for (int x = 0; x < n; ++x){ totals_comparison[x/10] &= a[x]; } for (int x = 0; x < (n/10 + 1); ++x){ if (totals_comparison[x] != totals[x]){ err += 1; break; } } for (int x = 0; x < n; x = x + 10){ temp_iterator = 0; for (ab_iterator = x; ab_iterator < n && ab_iterator < x + 10; ab_iterator+= 1){ temp_a[temp_iterator] = a[ab_iterator]; temp_b[temp_iterator] = b[ab_iterator]; } if (!is_possible(temp_a, temp_b, temp_iterator, 1)){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_expr_divided_x.c
#include "acc_testsuite.h" bool possible_result(real_t * remaining_combinations, int length, real_t current_value, real_t test_value){ if (length == 0){ if (fabs(current_value - test_value) > PRECISION){ return true; } else { return false; } } real_t * passed = (real_t *)malloc((length - 1) * sizeof(real_t)); for (int x = 0; x < length; ++x){ for (int y = 0; y < x; ++y){ passed[y] = remaining_combinations[y]; } for (int y = x + 1; y < length; ++y){ passed[y - 1] = remaining_combinations[y]; } if (possible_result(passed, length - 1, remaining_combinations[x] / current_value, test_value)){ free(passed); return true; } } free(passed); return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t *a = (real_t *)malloc(n * sizeof(real_t)); real_t *b = (real_t *)malloc(n * sizeof(real_t)); real_t *totals = (real_t *)malloc((n/10 + 1) * sizeof(real_t)); real_t * passed = (real_t *)malloc(10 * sizeof(real_t)); int indexer; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 1; } #pragma acc data copyin(a[0:n], b[0:n]) copy(totals[0:n/10 + 1]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic totals[x%(n/10 + 1)] = (a[x] + b[x]) / totals[x%(n/10 + 1)]; } } } for (int x = 0; x < (n/10 + 1); ++x){ indexer = x; while (indexer < n){ passed[indexer/(n/10 + 1)] = (a[x] + b[x]); indexer += (n/10 + 1); } if (!(possible_result(passed, 10, 1, totals[x]))){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_structured_bitxor_equals_assign.cpp
#include "acc_testsuite.h" bool is_possible(int* a, int* b, int length, int prev){ if (length == 0){ return true; } int *passed_a = new int[(length - 1)]; int *passed_b = new int[(length - 1)]; for (int x = 0; x < length; ++x){ if (b[x] == (prev ^ a[x])){ for (int y = 0; y < x; ++y){ passed_a[y] = a[y]; passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ passed_a[y - 1] = a[y]; passed_b[y - 1] = b[y]; } if (is_possible(passed_a, passed_b, length - 1, b[x])){ delete[] passed_a; delete[] passed_b; return true; } } } delete[] passed_a; delete[] passed_b; return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int *a = new int[n]; int *b = new int[n]; int *totals = new int[(n/10 + 1)]; int *totals_comparison = new int[(n/10 + 1)]; int *temp_a = new int[10]; int *temp_b = new int[10]; int temp_iterator; int ab_iterator; for (int x = 0; x < n; ++x){ for (int y = 0; y < 8; ++y){ if (rand()/(real_t)(RAND_MAX) < .933){ //.933 gets close to a 50/50 distribution for a collescence of 10 values a[x] += 1<<y; } } } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 0; totals_comparison[x] = 0; for (int y = 0; y < 8; ++y){ totals[x] += 1<<y; totals_comparison[x] += 1<<y; } } for (int x = 0; x < n; ++x){ b[x] = 0; } #pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) copyout(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic capture { totals[x/10] ^= a[x]; b[x] = totals[x/10]; } } } } for (int x = 0; x < n; ++x){ totals_comparison[x/10] ^= a[x]; } for (int x = 0; x < (n/10 + 1); ++x){ if (totals_comparison[x] != totals[x]){ err += 1; break; } } for (int x = 0; x < n; x = x + 10){ temp_iterator = 0; for (ab_iterator = x; ab_iterator < n && ab_iterator < x + 10; ab_iterator+= 1){ temp_a[temp_iterator] = a[ab_iterator]; temp_b[temp_iterator] = b[ab_iterator]; } if (!is_possible(temp_a, temp_b, temp_iterator, 1)){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_update_expr_rshift_x.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int *a = (unsigned int *)malloc(3 * n * sizeof(int)); unsigned int *b = (unsigned int *)malloc(n * sizeof(int)); int orders[18] = {1, 2, 0, 1, 0, 2, 2, 1, 0, 2, 0, 1, 0, 1, 2, 0, 2, 1}; int result; for (int x = 0; x < n; ++x){ for (int y = 0; y < 3; ++y){ a[x * 3 + y] = (int) (rand() / (unsigned int) (RAND_MAX / 4)); } b[x] = 0; } #pragma acc data copyin(a[0:3 * n]) copy(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop independent for (int y = 0; y < 3; ++y){ #pragma acc atomic update b[x] = a[x * 3 + y] >> b[x]; } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < 6; ++y){ result = 0; for (int z = 0; z < 3; ++z){ result = a[x * 3 + orders[y * 3 + z]] >> result; } if (result == b[x]){ break; } } if (result != b[x]){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_capture_rshift_equals.c
#include "acc_testsuite.h" bool is_possible(unsigned int a, unsigned int* b, int length, unsigned int prev){ if (length == 0){ return true; } unsigned int passed_a = 0; unsigned int *passed_b = (unsigned int *)malloc((length - 1) * sizeof(unsigned int)); for (int x = 0; x < length; ++x){ if ((b[x] == prev>>1 && ((a>>x)%2)==1) || ((a>>x)%2==0 && b[x] == prev)){ for (int y = 0; y < x; ++y){ if ((a>>y)%2 == 1){ passed_a += 1<<y; } passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ if ((a>>y) % 2 == 1){ passed_a += 1<<(y - 1); } passed_b[y - 1] = b[y]; } if (is_possible(passed_a, passed_b, length - 1, b[x])){ free(passed_b); return true; } } } free(passed_b); return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int *a = (unsigned int *)malloc(n * sizeof(int)); unsigned int *b = (unsigned int *)malloc(n * sizeof(int)); unsigned int *c = (unsigned int *)malloc(7 * n * sizeof(int)); unsigned int passed = 1<<8; for (int x = 0; x < n; ++x){ a[x] = 1<<8; for (int y = 0; y < 7; ++y){ if ((rand()/(real_t) (RAND_MAX)) > .5){ b[x] += 1<<y; } } } #pragma acc data copyin(b[0:n]) copy(a[0:n]) copyout(c[0:7*n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop for (int y = 0; y < 7; ++y){ c[x * 7 + y] = a[x]; if ((b[x]>>y)%2 == 1){ #pragma acc atomic capture c[x * 7 + y] = a[x] >>= 1; } } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < 7; ++y){ if ((b[x]>>y)%2 == 1){ a[x] <<= 1; } } if (a[x] != 1<<8){ err += 1; } } for (int x = 0; x < n; ++x){ if (!is_possible(b[x], &(c[x * 7]), 7, passed)){ err++; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/atomic_expr_minus_x.F90
RECURSIVE FUNCTION IS_POSSIBLE(subset, destination, length, init) RESULT(POSSIBLE) INTEGER, INTENT(IN) :: length REAL(8),DIMENSION(length), INTENT(IN) :: subset REAL(8), INTENT(IN) :: destination REAL(8), INTENT(IN) :: init REAL(8),ALLOCATABLE :: passed(:) LOGICAL :: POSSIBLE INTEGER :: x, y IF (length .gt. 0) THEN ALLOCATE(passed(length - 1)) ELSE IF (abs(init - destination) .gt. PRECISION) THEN POSSIBLE = .TRUE. ELSE POSSIBLE = .FALSE. END IF RETURN END IF POSSIBLE = .FALSE. DO x = 1, length DO y = 1, x - 1 passed(y) = subset(y) END DO DO y = x + 1, length passed(y - 1) = subset(y) END DO IF (IS_POSSIBLE(passed, destination, length - 1, subset(x) - init)) THEN POSSIBLE = .TRUE. RETURN END IF END DO END FUNCTION IS_POSSIBLE #ifndef T1 !T1:construct-independent,atomic,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators LOGICAL IS_POSSIBLE REAL(8),DIMENSION(LOOPCOUNT, 10):: a !Data REAL(8),DIMENSION(LOOPCOUNT):: totals INTEGER :: errors = 0 REAL(8),DIMENSION(10):: passed !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) totals = 0 !$acc data copyin(a(1:LOOPCOUNT, 1:10)) copy(totals(1:LOOPCOUNT)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT DO y = 1, 10 !$acc atomic totals(x) = a(x, y) - totals(x) END DO END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT DO y = 1, 10 passed(y) = a(x, y) END DO IF (IS_POSSIBLE(passed, totals(x), 10, 0) .eqv. .FALSE.) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/kernels_loop_reduction_and_vector_loop.F90
#ifndef T1 !T1:kernels,private,reduction,combined-constructs,loop,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators LOGICAL,DIMENSION(10*LOOPCOUNT):: a !Data LOGICAL,DIMENSION(10):: b LOGICAL,DIMENSION(10):: has_false LOGICAL :: temp REAL(8) :: false_margin REAL(8),DIMENSION(10*LOOPCOUNT) :: randoms INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) false_margin = exp(log(.5) / LOOPCOUNT) DO x = 1, 10 has_false(x) = .FALSE. b(x) = .TRUE. END DO DO x = 0, 9 DO y = 1, LOOPCOUNT IF (randoms(x * LOOPCOUNT + y) .lt. false_margin) THEN a(x * LOOPCOUNT + y) = .TRUE. ELSE a(x * LOOPCOUNT + y) = .FALSE. has_false(x + 1) = .TRUE. END IF END DO END DO !$acc data copyin(a(1:10*LOOPCOUNT)) copy(b(1:10)) !$acc kernels loop private(temp) DO x = 0, 9 temp = .TRUE. !$acc loop vector reduction(.AND.:temp) DO y = 1, LOOPCOUNT temp = temp .AND. a(x * LOOPCOUNT + y) END DO b(x + 1) = temp END DO !$acc end data DO x = 0, 9 temp = .FALSE. DO y = 1, LOOPCOUNT IF (a(x * LOOPCOUNT + y) .eqv. .FALSE.) THEN temp = .TRUE. END IF END DO IF (temp .neqv. has_false(x + 1)) THEN errors = 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/atomic_expr_lshift_x.c
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int *a = (unsigned int *)malloc(3 * n * sizeof(int)); unsigned int *b = (unsigned int *)malloc(n * sizeof(int)); int orders[18] = {1, 2, 0, 1, 0, 2, 2, 1, 0, 2, 0, 1, 0, 1, 2, 0, 2, 1}; int result; for (int x = 0; x < n; ++x){ for (int y = 0; y < 3; ++y){ a[x * 3 + y] = (int) (rand() / (unsigned int) (RAND_MAX / 4)); } b[x] = 0; } #pragma acc data copyin(a[0:3 * n]) copy(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop for (int y = 0; y < 3; ++y){ #pragma acc atomic b[x] = a[x * 3 + y] << b[x]; } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < 6; ++y){ result = 0; for (int z = 0; z < 3; ++z){ result = a[x * 3 + orders[y * 3 + z]] << result; } if (result == b[x]){ break; } } if (result != b[x]){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/acc_map_data.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test1(){ int err = 0; real_t *a = new real_t[n]; real_t *b = new real_t[n]; real_t *c = new real_t[n]; real_t *d; real_t *e = new real_t[n]; d = (real_t *)acc_malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } acc_map_data(c, d, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) present(c[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } } #pragma acc update host(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x]))> PRECISION){ err += 1; } } acc_unmap_data(c); acc_free(d); return err; } #endif #ifndef T2 //T2:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test2(){ int err = 0; real_t *a = new real_t[n]; real_t *b = new real_t[n]; real_t *c = new real_t[n]; real_t *d; real_t *e = new real_t[n]; d = (real_t *)acc_malloc(2 * n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } acc_map_data(c, d, n * sizeof(real_t)); acc_map_data(e, &(d[n]), n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) present(c[0:n], e[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ e[x] = a[x] * b[x]; } } } #pragma acc update host(c[0:n]) #pragma acc update host(e[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } if (fabs(e[x] - (a[x] * b[x])) > PRECISION){ err += 1; } } acc_unmap_data(c); acc_unmap_data(e); acc_delete(d, n * sizeof(real_t)); return err; } #endif #ifndef T3 //T3:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test3(){ int err = 0; real_t *a = new real_t[n]; real_t *b = new real_t[n]; real_t *c = new real_t[n]; real_t *d; real_t *e = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } d = (real_t *)acc_malloc(n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) deviceptr(d) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ d[x] = a[x] + b[x]; } } } acc_map_data(c, d, n * sizeof(real_t)); #pragma acc data copyin(a[0:n], b[0:n]) present(c[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] += a[x] + b[x]; } } } #pragma acc update host(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - 2 * (a[x] + b[x])) > 2 * PRECISION){ err += 1; } } acc_unmap_data(c); acc_delete(d, n * sizeof(real_t)); return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif return failcode; }
./openacc-vv/parallel_copyout.c
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,data,data-region,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (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.0; } #pragma acc data copyin(a[0:n]) { #pragma acc parallel copyout(b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err += 1; break; } } return err; } #endif #ifndef T2 //T2:parallel,data,data-region,devonly,V:2.0-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); int* hasDevice = (int *) malloc(sizeof(int)); hasDevice[0] = 1; #pragma acc enter data copyin(hasDevice[0:1]) #pragma acc parallel present(hasDevice[0:1]) { hasDevice[0] = 0; } if (hasDevice[0] == 1){ for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = a[x]; } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel copyout(b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = b[x] - a[x]; } } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err += 2; break; } } } return err; } #endif #ifndef T3 //T3:parallel,data,data-region,V:1.0-2.7 int test3(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = a[x]; } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel copyout(b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = b[x] - a[x]; } } #pragma acc update host(b[0:n]) } for (int x = 0; x < n; ++x){ if (fabs(b[x]) > 2 * PRECISION){ err += 4; break; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif return failcode; }
./openacc-vv/atomic_update_expr_lshift_x.c
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int *a = (unsigned int *)malloc(3 * n * sizeof(int)); unsigned int *b = (unsigned int *)malloc(n * sizeof(int)); int orders[18] = {1, 2, 0, 1, 0, 2, 2, 1, 0, 2, 0, 1, 0, 1, 2, 0, 2, 1}; int result; for (int x = 0; x < n; ++x){ for (int y = 0; y < 3; ++y){ a[x * 3 + y] = (int) (rand() / (unsigned int) (RAND_MAX / 4)); } b[x] = 0; } #pragma acc data copyin(a[0:3 * n]) copy(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc loop for (int y = 0; y < 3; ++y){ #pragma acc atomic update b[x] = a[x * 3 + y] << b[x]; } } } } for (int x = 0; x < n; ++x){ for (int y = 0; y < 6; ++y){ result = 0; for (int z = 0; z < 3; ++z){ result = a[x * 3 + orders[y * 3 + z]] << result; } if (result == b[x]){ break; } } if (result != b[x]){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/serial_loop_reduction_bitand_vector_loop.c
#include "acc_testsuite.h" #ifndef T1 //T1:serial,loop,reduction,combined-constructs,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); unsigned int* a = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int* b = (unsigned int *)malloc(10 * sizeof(unsigned int)); unsigned int b_host; unsigned int c = 0; real_t false_margin = pow(exp(1), log(.5)/n); unsigned int temp = 1; for (int x = 0; x < 10 * n; ++x){ for (int y = 0; y < 16; ++y){ if (rand() / (real_t) RAND_MAX < false_margin){ for (int z = 0; z < y; ++z){ temp *= 2; } a[x] += temp; temp = 1; } } } #pragma acc data copyin(a[0:10*n]) copy(b[0:10]) { #pragma acc serial loop private(c) for (int x = 0; x < 10; ++x){ c = a[x * n]; #pragma acc loop vector reduction(&:c) for (int y = 1; y < n; ++y){ c = c & a[x * n + y]; } b[x] = c; } } for (int x = 0; x < 10; ++x){ b_host = a[x * n]; for (int y = 1; y < n; ++y){ b_host = b_host & a[x * n + y]; } if (b_host != b[x]){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/kernels_loop_reduction_or_vector_loop.F90
#ifndef T1 !T1:kernels,private,reduction,combined-constructs,loop,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators LOGICAL,DIMENSION(10*LOOPCOUNT):: a !Data LOGICAL,DIMENSION(10) :: b LOGICAL :: temp REAL(8),DIMENSION(10*LOOPCOUNT):: randoms REAL(8) :: false_margin = exp(log(.5) / 2) INTEGER :: errors = 0 SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) !Initilization DO x = 1, 10 * LOOPCOUNT IF (randoms(x) > false_margin) THEN a(x) = .TRUE. ELSE a(x) = .FALSE. END IF END DO !$acc data copyin(a(1:10*LOOPCOUNT)), copy(b(1:10)) !$acc kernels loop private(temp) DO x = 0, 9 temp = .FALSE. !$acc loop vector reduction(.OR.:temp) DO y = 1, LOOPCOUNT temp = temp .OR. a(x * LOOPCOUNT + y) END DO b(x + 1) = temp END DO !$acc end data DO x = 0, 9 temp = .FALSE. DO y = 1, LOOPCOUNT temp = temp .OR. a(x * LOOPCOUNT + y) END DO IF (temp .neqv. b(x + 1)) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/acc_get_property.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,devonly,syntactic,V:2.6-2.7 int test1(){ int err = 0; if (acc_get_device_type() != acc_device_none){ const char* returned_string1; const char* returned_string2; const char* returned_string3; int returned_int; returned_int = acc_get_property(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_memory); returned_int = acc_get_property(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_free_memory); returned_string1 = acc_get_property_string(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_name); returned_string2 = acc_get_property_string(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_vendor); returned_string3 = acc_get_property_string(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_driver); } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/acc_get_default_async.c
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,async,construct-independent,internal-control-values,V:2.5-2.7 int test1(){ int err = 0; real_t *a = (real_t *)malloc(n * sizeof(real_t)); real_t *b = (real_t *)malloc(n * sizeof(real_t)); real_t *c = (real_t *)malloc(n * sizeof(real_t)); int holder = acc_get_default_async(); for(int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; } #pragma acc data copyin(a[0:n], b[0:n]) copyout(c[0:n]) { #pragma acc parallel async { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } #pragma acc wait(holder) } for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } if (acc_get_default_async() < 0){ err += 1; } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_loop_reduction_bitxor_general.F90
#ifndef T1 !T1:parallel,reduction,combined-constructs,loop,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators INTEGER,DIMENSION(LOOPCOUNT):: a !Data REAL(8),DIMENSION(LOOPCOUNT):: randoms INTEGER :: errors = 0 INTEGER :: b = 0 INTEGER :: temp = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) a = FLOOR(randoms*1000000) !$acc data copyin(a(1:LOOPCOUNT)) !$acc parallel loop reduction(ieor:b) DO x = 1, LOOPCOUNT b = ieor(b, a(x)) END DO !$acc end data DO x = 1, LOOPCOUNT temp = ieor(temp, a(x)) END DO IF (temp .ne. b) THEN errors = errors + 1 END IF IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/acc_deviceptr.c
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,data,executable-data,construct-independent,V:2.0-2.7 int test1(){ int err = 0; real_t *a = (real_t *)malloc(n * sizeof(real_t)); real_t *b = (real_t *)malloc(n * sizeof(real_t)); real_t *c = (real_t *)malloc(n * sizeof(real_t)); real_t *a_ptr; real_t *b_ptr; real_t *c_ptr; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; } #pragma acc enter data copyin(a[0:n], b[0:n]) create(c[0:n]) a_ptr = acc_deviceptr(a); b_ptr = acc_deviceptr(b); c_ptr = acc_deviceptr(c); #pragma acc data deviceptr(a_ptr, b_ptr, c_ptr) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ c_ptr[x] = a_ptr[x] + b_ptr[x]; } } } #pragma acc exit data copyout(c[0:n]) delete(a[0:n], b[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/set_device_num.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:set,devonly,runtime,construct-independent,V:2.5-2.7 int test1(){ int err = 0; if (acc_get_device_type() != acc_device_none){ real_t **host_copy = (real_t **)malloc(acc_get_num_devices(acc_get_device_type()) * sizeof(real_t *)); for (int x = 0; x < acc_get_num_devices(acc_get_device_type()); ++x){ host_copy[x] = new real_t[n]; } real_t *a = new real_t[n]; for (int x = 0; x < acc_get_num_devices(acc_get_device_type()); ++x){ for (int y = 0; y < n; ++y){ a[y] = rand() / (real_t)(RAND_MAX / 10); host_copy[x][y] = a[y]; } #pragma acc set device_num(x) #pragma acc enter data copyin(a[0:n]) } for (int x = 0; x < acc_get_num_devices(acc_get_device_type()); ++x){ #pragma acc set device_num(x) #pragma acc data present(a[0:n]) { #pragma acc parallel { #pragma acc loop for (int y = 0; y < n; ++y){ a[y] = a[y] + 1; } } } } for (int x = 0; x < acc_get_num_devices(acc_get_device_type()); ++x){ #pragma acc set device_num(x) #pragma acc exit data copyout(a[0:n]) for (int y = 0; y < n; ++y){ if (fabs(a[y] - (host_copy[x][y] + 1)) > PRECISION){ err += 1; } } } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_loop_reduction_add_vector_loop.c
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,private,reduction,combined-constructs,loop,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(10 * n * sizeof(real_t)); real_t * b = (real_t *)malloc(10 * n * sizeof(real_t)); real_t * c = (real_t *)malloc(10 * sizeof(real_t)); real_t temp = 0.0; for(int x = 0; x < 10 * n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:10*n], b[0:10*n]) copyout(c[0:10]) { #pragma acc parallel loop private(temp) for (int x = 0; x < 10; ++x){ temp = 0.0; #pragma acc loop vector reduction(+:temp) for (int y = 0; y < n; ++y){ temp += a[(x * n) + y] + b[(x * n) + y]; } c[x] = temp; } } for (int x = 0; x < 10; ++x){ for (int y = 0; y < n; ++y){ c[x] -= a[(x * n) + y] + b[(x * n) + y]; } if (fabs(c[x]) > PRECISION * (2 * n - 1)){ err = 1; } } return err; } #endif #ifndef T2 //T2:parallel,private,reduction,combined-constructs,loop,V:2.7-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(25 * n * sizeof(real_t)); real_t * b = (real_t *)malloc(25 * n * sizeof(real_t)); real_t * c = (real_t *)malloc(25 * sizeof(real_t)); real_t * c_host = (real_t *)malloc(25 * sizeof(real_t)); real_t temp[5]; for (int x = 0; x < 25 * n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } for (int x = 0; x < 25; ++x) { c[x] = 0; c_host[x] = 0; } #pragma acc data copyin(a[0:25*n], b[0:25*n]) copyout(c[0:25]) { #pragma acc parallel loop private(temp) for (int x = 0; x < 5; ++x) { for (int y = 0; y < 5; ++y) { temp[y] = 0; } #pragma acc loop vector reduction(+:temp) for (int y = 0; y < 5 * n; ++y) { temp[y % 5] += a[x * 5 * n + y] + b[x * 5 * n + y]; } for (int y = 0; y < 5; ++y) { c[x * 5 + y] = temp[y]; } } } for (int x = 0; x < 5; ++x) { for (int y = 0; y < 5 * n; ++y) { c_host[x * 5 + (y % 5)] += a[x * 5 * n + y] + b[x * 5 * n + y]; } } for (int x = 0; x < 25; ++x) { if (fabs(c[x] - c_host[x]) > PRECISION) { err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif return failcode; }
./openacc-vv/parallel_copyin.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,data,data-region,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * a_copy = new real_t[n]; real_t * b = new real_t[n]; int* hasDevice = (int *) malloc(sizeof(int)); hasDevice[0] = 1; #pragma acc enter data copyin(hasDevice[0:1]) #pragma acc parallel present(hasDevice[0:1]) { hasDevice[0] = 0; } for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); a_copy[x] = a[x]; b[x] = 0.0; } #pragma acc parallel copyin(a[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ a[x] = 0.0; } } for (int x = 0; x < n; ++x){ if (((fabs(a[x] - a_copy[x]) > PRECISION) && (hasDevice[0] == 1)) || ((hasDevice[0] == 0) && (fabs(a[x]) > PRECISION))){ err = 1; } } return err; } #endif #ifndef T2 //T2:parallel,data,data-region,V:1.0-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * a_copy = new real_t[n]; real_t * b = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copy(b[0:n]) { #pragma acc parallel copyin(a[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif return failcode; }
./openacc-vv/acc_set_default_async.F90
#ifndef T1 !T1:runtime,async,construct-independent,internal-control-values,set,V:2.5-2.7 LOGICAL FUNCTION test1() USE OPENACC IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c, a_host, b_host !Data INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) a_host = a b_host = b c = 0 !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) copyout(c(1:LOOPCOUNT)) CALL acc_set_default_async(1) !$acc parallel async !$acc loop DO x = 1, LOOPCOUNT a(x) = a(x) * a(x) END DO !$acc end parallel CALL acc_set_default_async(2) !$acc parallel async !$acc loop DO x = 1, LOOPCOUNT b(x) = b(x) * b(x) END DO !$acc end parallel !$acc parallel async(1) wait(2) !$acc loop DO x = 1, LOOPCOUNT c(x) = a(x) + b(x) END DO !$acc end parallel !$acc wait(1) !$acc end data DO x = 1, LOOPCOUNT IF (abs(c(x) - (a_host(x) * a_host(x) + b_host(x) * b_host(x))) .gt. 4 * PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" !Conditionally define test functions #ifndef T1 LOGICAL :: test1 #endif failcode = 0 failed = .FALSE. #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/kernels_loop_reduction_and_loop.F90
#ifndef T1 !T1:kernels,reduction,combined-constructs,loop,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators LOGICAL,DIMENSION(10*LOOPCOUNT):: a, a_copy !Data LOGICAL,DIMENSION(10) :: results, has_false LOGICAL :: host_results = .TRUE. LOGICAL :: temp = .TRUE. REAL(8),DIMENSION(10*LOOPCOUNT):: randoms REAL(8) :: false_margin = exp(log(.5) / LOOPCOUNT) INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) DO x = 1, 10 results(x) = .TRUE. has_false(x) = .FALSE. END DO DO x = 1, 10*LOOPCOUNT IF (randoms(x) .lt. false_margin) THEN a(x) = .TRUE. a_copy(x) = .TRUE. ELSE a(x) = .FALSE. a_copy(x) = .FALSE. has_false(x / LOOPCOUNT) = .TRUE. END IF END DO !$acc data copy(a(1:10*LOOPCOUNT), results(1:10)) !$acc kernels loop gang DO x = 0, 9 temp = .TRUE. !$acc loop worker reduction(.AND.:temp) DO y = 1, LOOPCOUNT temp = temp .AND. a(x * LOOPCOUNT + y) END DO results(x + 1) = temp !$acc loop worker DO y = 1, LOOPCOUNT IF (temp .eqv. .TRUE.) THEN IF (a(x * LOOPCOUNT + y) .eqv. .TRUE.) THEN a(x * LOOPCOUNT + y) = .FALSE. ELSE a(x * LOOPCOUNT + y) = .TRUE. END IF END IF END DO END DO !$acc end data DO x = 0, 9 temp = .TRUE. DO y = 1, LOOPCOUNT temp = temp .AND. a_copy(x * LOOPCOUNT + y) END DO IF (temp .neqv. results(x + 1)) THEN errors = errors + 1 END IF DO y = 1, LOOPCOUNT IF (temp .eqv. .TRUE.) THEN IF (a(x * LOOPCOUNT + y) .eqv. a_copy(x * LOOPCOUNT + y)) THEN errors = errors + 1 END IF ELSE IF (a(x * LOOPCOUNT + y) .neqv. a_copy(x * LOOPCOUNT + y)) THEN errors = errors + 1 END IF END IF END DO END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/acc_wait_async.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:runtime,async,construct-independent,wait,V:2.0-2.7 int test1(){ int err = 0; real_t *a = new real_t[n]; real_t *b = new real_t[n]; real_t *c = new real_t[n]; real_t *d = new real_t[n]; real_t *e = new real_t[n]; real_t *f = new real_t[n]; real_t *g = new real_t[n]; real_t *h = new real_t[n]; real_t *i = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0; d[x] = rand() / (real_t)(RAND_MAX / 10); e[x] = rand() / (real_t)(RAND_MAX / 10); f[x] = 0; g[x] = rand() / (real_t)(RAND_MAX / 10); h[x] = 0; i[x] = 0; } #pragma acc data copyin(a[0:n], b[0:n], d[0:n], e[0:n], g[0:n]) create(c[0:n], f[0:n], h[0:n]) copyout(i[0:n]) { #pragma acc parallel async(1) { #pragma acc loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } acc_wait_async(1, 2); #pragma acc parallel async(2) { #pragma acc loop for (int x = 0; x < n; ++x){ h[x] = c[x] + g[x]; } } #pragma acc parallel async(1) { #pragma acc loop for (int x = 0; x < n; ++x){ f[x] = d[x] + e[x]; } } acc_wait_async(1, 2); #pragma acc parallel async(2) { #pragma acc loop for (int x = 0; x < n; ++x){ i[x] = h[x] + f[x]; } } #pragma acc wait(2) } for (int x = 0; x < n; ++x){ if (fabs(i[x] - (a[x] + b[x] + g[x] + d[x] + e[x])) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/init_device_num.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:init,runtime,V:2.5-2.7 int test1(){ int err = 0; srand(SEED); int device_num = acc_get_device_num(acc_get_device_type()); #pragma acc init device_num(device_num) return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/serial_loop_reduction_bitor_vector_loop.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:serial,loop,reduction,combined-constructs,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); unsigned int* a = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int* b = (unsigned int *)malloc(10 * sizeof(unsigned int)); unsigned int b_host; real_t false_margin = pow(exp(1), log(.5)/n); unsigned int temp = 1; for (int x = 0; x < 10 * n; ++x){ for (int y = 0; y < 16; ++y){ if (rand() / (real_t) RAND_MAX > false_margin){ for (int z = 0; z < y; ++z){ temp *= 2; } a[x] += temp; temp = 1; } } } temp = 0; #pragma acc data copyin(a[0:10*n]) copy(b[0:10]) { #pragma acc serial loop private(temp) for (int x = 0; x < 10; ++x){ temp = 0; #pragma acc loop vector reduction(|:temp) for (int y = 0; y < n; ++y){ temp = temp | a[x * n + y]; } b[x] = temp; } } for (int x = 0; x < 10; ++x){ b_host = a[x * n]; for (int y = 1; y < n; ++y){ b_host = b_host | a[x * n + y]; } if (b_host != b[x]){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_loop_reduction_and_general.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,reduction,combined-constructs,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); char * a = new char[n]; real_t false_margin = pow(exp(1), log(.5)/n); char result = 1; char found = 0; for (int x = 0; x < n; ++x){ if(rand() / (real_t)(RAND_MAX) < false_margin){ a[x] = 1; } else{ a[x] = 0; } } #pragma acc data copyin(a[0:n]) { #pragma acc parallel loop reduction(&&:result) for (int x = 0; x < n; ++x){ result = result && a[x]; } } for (int x = 0; x < n; ++x){ if (a[x] == 0){ found = 1; break; } } if (found == result){ err = 1; } return err; } #endif #ifndef T2 //T2:parallel,combined-constructs,loop,V:2.7-2.7 int test2(){ int err = 0; srand(SEED); char * a = new char[n * 5]; real_t false_margin = pow(exp(1), log(.5/n)); char result[5]; char host_result[5]; for (int x = 0; x < 5; ++x) { result[x] = 1; host_result[x] = 1; } for (int x = 0; x < 5 * n; ++x) { if (rand() / (real_t)(RAND_MAX) < false_margin) { a[x] = 1; } else { a[x] = 0; } } #pragma acc data copyin(a[0:5*n]) { #pragma acc parallel loop reduction(&&:result) for (int x = 0; x < 5 * n; ++x) { result[x%5] = result[x%5] && a[x]; } } for (int x = 0; x < 5 * n; ++x) { host_result[x%5] = host_result[x%5] && a[x]; } for (int x = 0; x < 5; ++x){ if (host_result[x] != result[x]) { err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif return failcode; }
./openacc-vv/serial_reduction.c
#include "acc_testsuite.h" #ifndef T1 //T1:serial,reduction,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t reduction; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc serial copyin(a[0:n]) reduction(+:reduction) { #pragma acc loop for (int x = 0; x < n; ++x){ reduction = reduction + a[x]; } } for (int x = 0; x < n; ++x){ reduction = reduction - a[x]; } if (fabs(reduction) > PRECISION){ err += 1; } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/kernels_present.c
#include "acc_testsuite.h" #ifndef T1 //T1:kernels,data,structured-data,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (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.0; } #pragma acc enter data copyin(a[0:n]) create(b[0:n]) #pragma acc kernels present(a[0:n], b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } #pragma acc exit data copyout(b[0:n]) delete(a[0:n]) for (int x = 0; x < n; ++x){ if (fabs(b[x] - a[x]) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/data_create_no_lower_bound.F90
#ifndef T1 !T1:data,data_region,construct-independent,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c, d, e !Data INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 0 CALL RANDOM_NUMBER(d) e = 0 !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT), d(1:LOOPCOUNT)) create(c(:LOOPCOUNT)) copyout(e(1:LOOPCOUNT)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT c(x) = a(x) + b(x) END DO !$acc loop DO x = 1, LOOPCOUNT e(x) = c(x) + d(x) END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT IF (abs(e(x) - (a(x) + b(x) + d(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/parallel_firstprivate.F90
#ifndef T1 !T1:parallel,firstprivate,V:1.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators REAL(8),DIMENSION(10 * LOOPCOUNT):: a, b, d !Data REAL(8),DIMENSION(LOOPCOUNT):: c, c_copy REAL*8 :: RAND INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) CALL RANDOM_NUMBER(c) c_copy = c d = 0 !$acc data copyin(a(1:10*LOOPCOUNT), b(1:10*LOOPCOUNT)) copy(d(1:10*LOOPCOUNT)) !$acc parallel firstprivate(c(1:LOOPCOUNT)) !$acc loop gang DO x = 0, 9 !$acc loop worker DO y = 1, LOOPCOUNT d(x * LOOPCOUNT + y) = a(x * LOOPCOUNT + y) + b(x * LOOPCOUNT + y) + c(y) END DO END DO !$acc end parallel !$acc end data DO x = 0, 9 DO y = 1, LOOPCOUNT IF (abs(d(x * LOOPCOUNT + y) - (a(x * LOOPCOUNT + y) + b(x * LOOPCOUNT + y) + c(y))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif #ifndef T2 !T2:parallel,firstprivate,V:1.0-2.7 LOGICAL FUNCTION test2() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators REAL(8),DIMENSION(10 * LOOPCOUNT):: a, b, d !Data REAL(8),DIMENSION(LOOPCOUNT):: c, c_copy REAL*8 :: RAND INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 0 d = 0 !$acc data copyin(a(1:10*LOOPCOUNT), b(1:10*LOOPCOUNT)) copy(d(1:10*LOOPCOUNT)) !$acc parallel firstprivate(c(1:LOOPCOUNT)) !$acc loop gang independent DO x = 0, 9 !$acc loop worker independent DO y = 1, LOOPCOUNT c(y) = a(x * LOOPCOUNT + y) - b(x * LOOPCOUNT + y) END DO !$acc loop worker independent DO y = 1, LOOPCOUNT d(x * LOOPCOUNT + y) = a(x * LOOPCOUNT + y) + b(x * LOOPCOUNT + y) + c(y) END DO END DO !$acc end parallel !$acc end data DO x = 1, 10 * LOOPCOUNT IF (abs(d(x) - (2 * a(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test2 = .FALSE. ELSE test2 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif #ifndef T2 LOGICAL :: test2 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif #ifndef T2 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test2() END DO IF (failed) THEN failcode = failcode + 2 ** 1 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/serial_copyin.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:serial,data,data-region,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * a_copy = new real_t[n]; real_t * b = new real_t[n]; int* hasDevice = (int *) malloc(sizeof(int)); hasDevice[0] = 1; #pragma acc enter data copyin(hasDevice[0:1]) #pragma acc parallel present(hasDevice[0:1]) { hasDevice[0] = 0; } for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); a_copy[x] = a[x]; b[x] = 0.0; } #pragma acc serial copyin(a[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ a[x] = 0.0; } } for (int x = 0; x < n; ++x){ if (((fabs(a[x] - a_copy[x]) > PRECISION) && (hasDevice[0] == 1)) || ((hasDevice[0] == 0) && (fabs(a[x]) > PRECISION))){ err = 1; } } return err; } #endif #ifndef T2 //T2:serial,data,data-region,V:2.6-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * a_copy = new real_t[n]; real_t * b = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copy(b[0:n]) { #pragma acc serial copyin(a[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif return failcode; }
./openacc-vv/parallel_loop_async.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,loop,async,combined-constructs,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[10 * n]; real_t * b = new real_t[10 * n]; real_t * c = new real_t[10 * n]; real_t * d = new real_t[10 * n]; int * errors = new int[10]; for (int x = 0; x < 10; ++x){ errors[x] = 0; } for (int x = 0; x < 10 * n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; d[x] = a[x] + b[x]; } #pragma acc data copyin(a[0:10*n], b[0:10*n], c[0:10*n], d[0:10*n]) copy(errors[0:10]) { for (int x = 0; x < 10; ++x){ #pragma acc parallel loop async(x) for (int y = 0; y < n; ++y){ c[x * n + y] = a[x * n + y] + b[x * n + y]; } #pragma acc parallel loop async(x) reduction(+:errors[x]) for (int y = 0; y < n; ++y){ if(c[x * n + y] - d[x * n + y] > PRECISION || d[x * n + y] - c[x * n + y] > PRECISION){ errors[x] += 1; } } } #pragma acc wait } for (int x = 0; x < 10; ++x){ err += errors[x]; } return err; } #endif #ifndef T2 //T2:parallel,loop,async,combined-constructs,V:1.0-2.7 int test2(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; real_t * b = new real_t[n]; real_t * c = new real_t[n]; real_t * d = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = a[x] * 2; c[x] = rand() / (real_t)(RAND_MAX / 10); d[x] = c[x] * 2; } #pragma acc parallel loop copy(a[0:n]) async(0) for(int x = 0; x < n; ++x) { a[x] = a[x] * 2; } #pragma acc parallel loop copy(c[0:n]) async(0) for(int x = 0; x < n; ++x) { c[x] = c[x] * 2; } #pragma acc wait for (int x = 0; x < n; ++x){ if(a[x] != b[x] || c[x] != d[x]) err = 1; } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif return failcode; }
./openacc-vv/parallel_if.F90
#ifndef T1 !T1:devonly,parallel,if,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c !Data INTEGER :: errors = 0 LOGICAL :: host = .FALSE. LOGICAL :: device = .TRUE. INTEGER,DIMENSION(1) :: dev_test dev_test(1) = 0 !$acc enter data copyin(dev_test(1:1)) !$acc parallel present(dev_test(1:1)) dev_test(1) = 1 !$acc end parallel !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 0 !$acc parallel if(host) !$acc loop DO x = 1, LOOPCOUNT c(x) = a(x) + b(x) END DO !$acc end parallel DO x = 1, LOOPCOUNT IF (abs(c(x) - (a(x) + b(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif #ifndef T2 !T2:devonly,parallel,if,V:2.0-2.7 LOGICAL FUNCTION test2() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c !Data INTEGER :: errors = 0 LOGICAL :: host = .FALSE. LOGICAL :: device = .TRUE. INTEGER,DIMENSION(1) :: dev_test dev_test(1) = 0 !$acc enter data copyin(dev_test(1:1)) !$acc parallel present(dev_test(1:1)) dev_test(1) = 1 !$acc end parallel !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) IF (dev_test(1) .eq. 0) THEN CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = a + b !$acc enter data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT), c(1:LOOPCOUNT)) !$acc parallel if(host) present(a(1:LOOPCOUNT), b(1:LOOPCOUNT), c(1:LOOPCOUNT)) !$acc loop DO x = 1, LOOPCOUNT c(x) = c(x) + a(x) + b(x) END DO !$acc end parallel !$acc exit data delete(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) copyout(c(1:LOOPCOUNT)) DO x = 1, LOOPCOUNT IF (abs(c(x) - (a(x) + b(x))) .gt. PRECISION) THEN errors = errors + 1 END IF END DO END IF IF (errors .eq. 0) THEN test2 = .FALSE. ELSE test2 = .TRUE. END IF END #endif #ifndef T3 !T3:devonly,parallel,if,V:2.0-2.7 LOGICAL FUNCTION test3() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c !Data INTEGER :: errors = 0 LOGICAL :: host = .FALSE. LOGICAL :: device = .TRUE. INTEGER,DIMENSION(1) :: dev_test dev_test(1) = 0 !$acc enter data copyin(dev_test(1:1)) !$acc parallel present(dev_test(1:1)) dev_test(1) = 1 !$acc end parallel !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = a + b !$acc enter data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT), c(1:LOOPCOUNT)) !$acc parallel if(device) present(a(1:LOOPCOUNT), b(1:LOOPCOUNT), c(1:LOOPCOUNT)) !$acc loop DO x = 1, LOOPCOUNT c(x) = c(x) + a(x) + b(x) END DO !$acc end parallel !$acc exit data delete(a(1:LOOPCOUNT), b(1:LOOPCOUNT)), copyout(c(1:LOOPCOUNT)) DO x = 1, LOOPCOUNT IF (abs(c(x) - (2 * (a(x) + b(x)))) .gt. 2 * PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test3 = .FALSE. ELSE test3 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif #ifndef T2 LOGICAL :: test2 #endif #ifndef T3 LOGICAL :: test3 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif #ifndef T2 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test2() END DO IF (failed) THEN failcode = failcode + 2 ** 1 failed = .FALSE. END IF #endif #ifndef T3 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test3() END DO IF (failed) THEN failcode = failcode + 2 ** 2 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/kernels_async.F90
#ifndef T1 !T1:async,kernels,update,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b, c, d, e, f, g !Data INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) c = 0 CALL RANDOM_NUMBER(d) CALL RANDOM_NUMBER(e) f = 0 g = 0 !$acc enter data create(g(1:LOOPCOUNT), c(1:LOOPCOUNT), f(1:LOOPCOUNT)) !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT), d(1:LOOPCOUNT), e(1:LOOPCOUNT)) !$acc kernels async(1) !$acc loop DO x = 1, LOOPCOUNT c(x) = a(x) + b(x) END DO !$acc end kernels !$acc kernels async(2) !$acc loop DO x = 1, LOOPCOUNT f(x) = d(x) + e(x) END DO !$acc end kernels !$acc kernels wait(1, 2) async(3) !$acc loop DO x = 1, LOOPCOUNT g(x) = c(x) + f(x) END DO !$acc end kernels !$acc end data !$acc wait(1, 2) !$acc update host(c(1:LOOPCOUNT), f(1:LOOPCOUNT)) !$acc exit data copyout(g(1:LOOPCOUNT)) async(3) DO x = 1, LOOPCOUNT IF (abs(c(x) - (a(x) + b(x))) .gt. PRECISION) THEN errors = errors + 1 WRITE(*, *) x, " a: ", c(x), " = ", a(x), " + ", b(x) END IF IF (abs(f(x) - (d(x) + e(x))) .gt. PRECISION) THEN errors = errors + 1 WRITE(*, *) x, " b: ", f(x), " = ", d(x), " + ", e(x) END IF END DO !$acc wait(3) DO x = 1, LOOPCOUNT IF (abs(g(x) - (c(x) + f(x))) .gt. PRECISION) THEN errors = errors + 1 WRITE(*, *) x, " c: ", g(x), " = ", c(x), " + ", f(x) END IF END DO !$acc exit data delete(c(1:LOOPCOUNT), f(1:LOOPCOUNT)) IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/atomic_update_x_multiply_expr.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); real_t *a = new real_t[n]; real_t *b = new real_t[n]; real_t *totals = new real_t[(n/10 + 1)]; real_t *totals_comparison = new real_t[(n/10 + 1)]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 1; totals_comparison[x] = 1; } #pragma acc data copyin(a[0:n], b[0:n]) copy(totals[0:n/10 + 1]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic update totals[x%(n/10 + 1)] = totals[x%(n/10 + 1)] * (a[x] + b[x]); } } } for (int x = 0; x < n; ++x){ totals_comparison[x%(n/10 + 1)] *= a[x] + b[x]; } for (int x = 0; x < 10; ++x){ if (fabs(totals_comparison[x] - totals[x]) > PRECISION * totals_comparison[x]){ err += 1; break; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/kernels_if.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:kernels,if,V:1.0-3.2 int test1(){ int err = 0; srand(SEED); int data_on_device = 0; real_t * a = new real_t[n]; real_t * b = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = 0; } #pragma acc kernels if(data_on_device) present(a[0:n], b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } for (int x = 0; x < n; ++x){ if (fabs(b[x] - a[x]) > PRECISION){ err += 1; } } return err; } #endif #ifndef T2 //T2:kernels,if,V:2.0-3.2 int test2(){ int err = 0; srand(SEED); int data_on_device = 0; int * devtest = (int *)malloc(sizeof(int)); real_t * a = new real_t[n]; real_t * b = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = 0; } #pragma acc enter data copyin(a[0:n]) create(b[0:n]) data_on_device = 1; #pragma acc kernels if(data_on_device) present(a[0:n], b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } #pragma acc exit data copyout(b[0:n]) delete(a[0:n]) for (int x = 0; x < n; ++x){ if (fabs(b[x] - a[x]) > PRECISION){ err += 1; } } return err; } #endif #ifndef T3 //T3:kernels,if,devonly,V:2.0-3.2 int test3(){ int err = 0; srand(SEED); int data_on_device = 0; int * devtest = (int *)malloc(sizeof(int)); real_t * a = new real_t[n]; real_t * b = new real_t[n]; devtest[0] = 1; #pragma acc enter data copyin(devtest[0:1]) #pragma acc parallel present(devtest[0:1]) { devtest[0] = 0; } if (devtest[0] == 1){ for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = 0; } #pragma acc enter data copyin(a[0:n]) create(b[0:n]) for (int x = 0; x < n; ++x){ a[x] = -1; } #pragma acc kernels if(data_on_device) present(a[0:n], b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } for (int x = 0; x < n; ++x){ if (fabs(a[x] + 1) > PRECISION){ err += 1; } if (fabs(b[x] + 1) > PRECISION){ err += 1; } } #pragma acc exit data copyout(a[0:n], b[0:n]) data_on_device = 0; for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION){ err += 1; } } } return err; } #endif #ifndef T4 //T4:kernels,if,devonly,V:2.0-3.2 int test4(){ int err = 0; srand(SEED); int data_on_device = 0; int * devtest = (int *)malloc(sizeof(int)); real_t * a = new real_t[n]; real_t * b = new real_t[n]; devtest[0] = 1; #pragma acc enter data copyin(devtest[0:1]) #pragma acc parallel present(devtest[0:1]) { devtest[0] = 0; } if (devtest[0] == 1){ for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = 0; } #pragma acc enter data copyin(a[0:n], b[0:n]) #pragma acc kernels if(data_on_device) present(a[0:n], b[0:n]) { #pragma acc loop for (int x = 0; x < n; ++x){ b[x] = a[x]; } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - b[x]) > PRECISION) { err += 1; } } #pragma acc exit data copyout(a[0:n], b[0:n]) for (int x = 0; x < n; ++x){ if (fabs(b[x]) > PRECISION && b[x] != a[x]){ err += 1; } } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif #ifndef T4 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test4(); } if (failed != 0){ failcode = failcode + (1 << 3); } #endif return failcode; }
./openacc-vv/kernels_loop_reduction_bitxor_loop.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:kernels,loop,reduction,combined-constructs,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned int * a = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int * b = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int * b_copy = (unsigned int *)malloc(10 * n * sizeof(unsigned int)); unsigned int * c = (unsigned int *)malloc(10 * sizeof(unsigned int)); unsigned int temp = 0; for (int x = 0; x < 10*n; ++x){ b[x] = (unsigned int) rand() / (real_t)(RAND_MAX / 1000); b_copy[x] = b[x]; a[x] = (unsigned int) rand() / (real_t)(RAND_MAX / 1000); } for (int x = 0; x < 10; ++x){ c[x] = 0; } #pragma acc data copyin(a[0:10*n]) copy(b[0:10*n], c[0:10]) { #pragma acc kernels loop gang private(temp) for (int x = 0; x < 10; ++x){ temp = 0; #pragma acc loop worker reduction(^:temp) for (int y = 0; y < n; ++y){ temp = temp ^ a[x * n + y]; } c[x] = temp; #pragma acc loop worker for (int y = 0; y < n; ++y){ b[x * n + y] = b[x * n + y] + c[x]; } } } for (int x = 0; x < 10; ++x){ temp = 0; for (int y = 0; y < n; ++y){ temp = temp ^ a[x * n + y]; } if (temp != c[x]){ err += 1; } for (int y = 0; y < n; ++y){ if (b[x * n + y] != b_copy[x * n + y] + c[x]){ err += 1; } } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/reference_count_zero.c
#include "acc_testsuite.h" #ifndef T1 //T1:reference-counting,data,V:3.2-3.3 int test1(){ int err = 0; srand(SEED); real_t * a = (real_t *)malloc(n * sizeof(real_t)); real_t * b = (real_t *)malloc(n * sizeof(real_t)); real_t * c = (real_t *)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); c[x] = 0.0; } #pragma acc data copy(a[0:n], b[0:n], c[0:n]) { #pragma acc parallel loop for (int x = 0; x < n; ++x){ c[x] = a[x] + b[x]; } } #pragma acc exit data copyout(c[0:n]) for (int x = 0; x < n; ++x){ if (fabs(c[x] - (a[x] + b[x])) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/routine_bind_nonprototype_lambda_string_function.cpp
#include "acc_testsuite.h" //test 1 host lambnda #pragma acc routine vector bind("device_array_array") auto host_array_array = [](real_t * a, long long n){ #pragma acc loop reduction(+:returned) real_t returned = 0.0; for (int x = 0; x < n; ++x){ returned += a[x]; } return returned; }; //test 1 device function real_t device_array_array(real_t * a, long long n){ real_t returned = 0.0; #pragma acc loop reduction(-:returned) for (int x = 0; x < n; ++x){ returned -= a[x]; } return returned; } //test 2 host lambda #pragma acc routine vector bind("device_object_array") auto host_object_array = [](data_container<real_t> * a, long long n){ real_t returned = 0.0; #pragma acc loop reduction(-:returned) for(int x = 0; x < n; ++x){ returned += a->data[x]; } return returned; }; //test 2 device function real_t device_object_array(data_container<real_t> *a, long long n){ real_t returned = 0.0; #pragma acc loop reduction(-:returned) for(int x = 0; x < n; ++x){ returned -= a->data[x]; } return returned; } //test 3 host lambda #pragma acc routine vector bind("device_array_object") auto host_array_object = [](real_t * a, long long n){ #pragma acc loop reduction(+:returned) real_t returned = 0.0; for (int x = 0; x < n; ++x){ returned += a[x]; } return returned; }; //test 3 device function real_t device_array_object(real_t * a, long long n){ real_t returned = 0.0; #pragma acc loop reduction(-:returned) for (int x = 0; x < n; ++x){ returned -= a[x]; } return returned; } //test 4 host lambda #pragma acc routine vector bind("device_object_object") auto host_object_object = [](data_container<real_t> * a, long long n){ real_t returned = 0.0; #pragma acc loop reduction(-:returned) for(int x = 0; x < n; ++x){ returned += a->data[x]; } return returned; }; //test 4 device function real_t device_object_object(data_container<real_t> *a, long long n){ real_t returned = 0.0; #pragma acc loop reduction(-:returned) for(int x = 0; x < n; ++x){ returned -= a->data[x]; } return returned; } #ifndef T1 //T1:routine,V:2.7-3.3 int test1(){ int err = 0; srand(SEED); real_t *a = new real_t[n]; real_t *b = new real_t[n]; int on_host = (acc_get_device_type() == acc_device_none); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = 0; } #pragma acc data copyin(a[0:n]) copyout(b[0:n]) { #pragma acc parallel { #pragma acc loop gang worker vector for (int x = 0; x < n; ++x){ b[x] = device_array_array(a, n); } } } for (int x = 0; x < n; ++x){ if ((!on_host) && (fabs(host_array_array(a, n) + b[x]) > PRECISION)){ err += 1; } else if ((on_host) && (fabs(host_array_array(a, n) - b[x]) > PRECISION)){ err += 1; } } delete[] a; delete[] b; return err; } #endif #ifndef T2 //T2:routine,V:2.7-3.3 int test2(){ int err = 0; srand(SEED); data_container<real_t> a = *(new data_container<real_t>(n)); real_t *b = new real_t[n]; int on_host = (acc_get_device_type() == acc_device_none); for (int x = 0; x < n; ++x){ a.data[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = 0; } #pragma acc data copyin(a, a.data[0:n]) copyout(b[0:n]) { #pragma acc parallel { #pragma acc loop gang worker vector for (int x = 0; x < n; ++x){ b[x] = device_object_array(&a, n); } } } for (int x = 0; x < n; ++x){ if ((!on_host) && (fabs(host_object_array(&a, n) + b[x]) > PRECISION)){ err += 1; } else if ((on_host) && (fabs(host_object_array(&a, n) - b[x]) > PRECISION)){ err += 1; } } delete[] b; return err; } #endif #ifndef T3 //T3:routine,V:2.7-3.3 int test3(){ int err = 0; srand(SEED); real_t *a = new real_t[n]; data_container<real_t> b = *(new data_container<real_t>(n)); int on_host = (acc_get_device_type() == acc_device_none); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b.data[x] = 0.0; } #pragma acc data copyin(a[0:n], b, b.data[0:n]) { #pragma acc parallel { #pragma acc loop gang worker vector for (int x = 0; x < n; ++x){ b.data[x] = device_array_object(a, n); } } #pragma acc update host(b.data[0:n]) } for (int x = 0; x < n; ++x){ if ((!on_host) && (fabs(host_array_object(a, n) + b.data[x]) > PRECISION)){ err += 1; } else if ((on_host) && (fabs(host_array_object(a, n) - b.data[x]) > PRECISION)){ err += 1; } } delete[] a; return err; } #endif #ifndef T4 //T4:routine,V:2.7-3.3 int test4(){ int err = 0; srand(SEED); data_container<real_t> a = *(new data_container<real_t>(n)); data_container<real_t> b = *(new data_container<real_t>(n)); int on_host = (acc_get_device_type() == acc_device_none); for (int x = 0; x < n; ++x){ a.data[x] = rand() / (real_t)(RAND_MAX / 10); b.data[x] = 0.0; } #pragma acc data copyin(a, a.data[0:n], b ,b.data[0:n]) { #pragma acc parallel { #pragma acc loop gang worker vector for (int x = 0; x < n; ++x){ b.data[x] = device_object_object(&a, n); } } #pragma acc update host(b.data[0:n]) } for (int x = 0; x < n; ++x){ if ((!on_host) && (fabs(host_object_object(&a, n) + b.data[x]) > PRECISION)){ err += 1; } else if ((on_host) && (fabs(host_object_object(&a, n) - b.data[x]) > PRECISION)){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed = 0; #ifndef T1 failed = 0; for(int x = 0; x < NUM_TEST_CALLS; ++x){ failed += test1(); } if(failed){ failcode += (1 << 0); } #endif #ifndef T2 failed = 0; for(int x = 0; x < NUM_TEST_CALLS; ++x){ 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){ failcode += (1 << 2); } #endif #ifndef T4 failed = 0; for(int x = 0; x < NUM_TEST_CALLS; ++x){ failed += test4(); } if(failed){ failcode += (1 << 3); } #endif return failcode; }
./openacc-vv/parallel_loop_reduction_add_general_type_check_pt2.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test1(){ int err = 0; srand(SEED); unsigned short int * a = (unsigned short int*)malloc(n * sizeof(unsigned short int)); unsigned short int * b = (unsigned short int *)malloc(n * sizeof(unsigned short int)); unsigned short int total = 10; unsigned short int host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (host_total != total) { err += 1; } return err; } #endif #ifndef T2 //T2:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test2(){ int err = 0; srand(SEED); unsigned int * a = (unsigned int *)malloc(n * sizeof(unsigned int)); unsigned int * b = (unsigned int *)malloc(n * sizeof(unsigned int)); unsigned int total = 10; unsigned int host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (host_total != total) { err += 1; } return err; } #endif #ifndef T3 //T3:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test3(){ int err = 0; srand(SEED); unsigned long int * a = (unsigned long int *)malloc(n * sizeof(unsigned long int)); unsigned long int * b = (unsigned long int *)malloc(n * sizeof(unsigned long int)); unsigned long int total = 10; unsigned long int host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (host_total != total) { err += 1; } return err; } #endif #ifndef T4 //T4:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test4(){ int err = 0; srand(SEED); unsigned long long int * a = (unsigned long long int *)malloc(n * sizeof(unsigned long long int)); unsigned long long int * b = (unsigned long long int *)malloc(n * sizeof(unsigned long long int)); unsigned long long int total = 10; unsigned long long int host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (total != host_total) { err += 1; } return err; } #endif #ifndef T5 //T5:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test5(){ int err = 0; srand(SEED); float * a = new float[n]; float * b = new float[n]; float total = 10; float host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (fabsf(total - host_total) > PRECISION) { err += 1; } return err; } #endif #ifndef T6 //T6:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test6(){ int err = 0; srand(SEED); double * a = new double[n]; double * b = new double[n]; double total = 10; double host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (fabs(host_total - total) > PRECISION) { err += 1; } return err; } #endif #ifndef T7 //T7:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test7(){ int err = 0; srand(SEED); long double * a = (long double *)malloc(n * sizeof(long double)); long double * b = (long double *)malloc(n * sizeof(long double)); long double total = 10; long double host_total = 10; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = rand() / (real_t)(RAND_MAX / 10); } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x){ total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (fabsl(host_total - total) > PRECISION) { err += 1; } return err; } #endif #ifndef T8 //T8:parallel,reduction,combined-constructs,loop,V:1.0-2.7 int test8(){ int err = 0; srand(SEED); float _Complex * a = (float _Complex *)malloc(n * sizeof(float _Complex)); float _Complex * b = (float _Complex *)malloc(n * sizeof(float _Complex)); float _Complex total = 10 + 10 * I; float _Complex host_total = 10 + 10 * I; for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10) + rand() / (real_t)(RAND_MAX / 10) * I; b[x] = rand() / (real_t)(RAND_MAX / 10) + rand() / (real_t)(RAND_MAX / 10) * I; } #pragma acc data copyin(a[0:n], b[0:n]) { #pragma acc parallel loop reduction(+:total) for (int x = 0; x < n; ++x) { total += a[x] + b[x]; } } for (int x = 0; x < n; ++x) { host_total += a[x] + b[x]; } if (fabsf(crealf(total) - crealf(host_total)) > PRECISION) { err += 1; } if (fabsf(cimagf(total) - cimagf(host_total)) > PRECISION) { err += 1; } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif #ifndef T2 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test2(); } if (failed != 0){ failcode = failcode + (1 << 1); } #endif #ifndef T3 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test3(); } if (failed != 0){ failcode = failcode + (1 << 2); } #endif #ifndef T4 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test4(); } if (failed != 0){ failcode = failcode + (1 << 3); } #endif #ifndef T5 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test5(); } if (failed != 0){ failcode = failcode + (1 << 4); } #endif #ifndef T6 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test6(); } if (failed != 0){ failcode = failcode + (1 << 5); } #endif #ifndef T7 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test7(); } if (failed != 0){ failcode = failcode + (1 << 6); } #endif #ifndef T8 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test8(); } if (failed != 0){ failcode = failcode + (1 << 7); } #endif return failcode; }
./openacc-vv/atomic_structured_expr_bitxor_x_assign.c
#include "acc_testsuite.h" bool is_possible(int* a, int* b, int length, int prev){ if (length == 0){ return true; } int *passed_a = (int *)malloc((length - 1) * sizeof(int)); int *passed_b = (int *)malloc((length - 1) * sizeof(int)); for (int x = 0; x < length; ++x){ if (b[x] == (prev ^ a[x])){ for (int y = 0; y < x; ++y){ passed_a[y] = a[y]; passed_b[y] = b[y]; } for (int y = x + 1; y < length; ++y){ passed_a[y - 1] = a[y]; passed_b[y - 1] = b[y]; } if (is_possible(passed_a, passed_b, length - 1, b[x])){ free(passed_a); free(passed_b); return true; } } } free(passed_a); free(passed_b); return false; } #ifndef T1 //T1:atomic,construct-independent,V:2.0-2.7 int test1(){ int err = 0; srand(SEED); int *a = (int *)malloc(n * sizeof(int)); int *b = (int *)malloc(n * sizeof(int)); int *totals = (int *)malloc((n/10 + 1) * sizeof(int)); int *totals_comparison = (int *)malloc((n/10 + 1) * sizeof(int)); int *temp_a = (int *)malloc(10 * sizeof(int)); int *temp_b = (int *)malloc(10 * sizeof(int)); int temp_iterator; int ab_iterator; for (int x = 0; x < n; ++x){ for (int y = 0; y < 8; ++y){ if (rand()/(real_t)(RAND_MAX) < .933){ //.933 gets close to a 50/50 distribution for a collescence of 10 values a[x] += 1<<y; } } } for (int x = 0; x < n/10 + 1; ++x){ totals[x] = 0; totals_comparison[x] = 0; for (int y = 0; y < 8; ++y){ totals[x] += 1<<y; totals_comparison[x] += 1<<y; } } for (int x = 0; x < n; ++x){ b[x] = 0; } #pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) copyout(b[0:n]) { #pragma acc parallel { #pragma acc loop for (int x = 0; x < n; ++x){ #pragma acc atomic capture { totals[x/10] = a[x] ^ totals[x/10]; b[x] = totals[x/10]; } } } } for (int x = 0; x < n; ++x){ totals_comparison[x/10] ^= a[x]; } for (int x = 0; x < (n/10 + 1); ++x){ if (totals_comparison[x] != totals[x]){ err += 1; break; } } for (int x = 0; x < n; x = x + 10){ temp_iterator = 0; for (ab_iterator = x; ab_iterator < n && ab_iterator < x + 10; ab_iterator+= 1){ temp_a[temp_iterator] = a[ab_iterator]; temp_b[temp_iterator] = b[ab_iterator]; } if (!is_possible(temp_a, temp_b, temp_iterator, 1)){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/kernels_copyout.F90
#ifndef T1 !T1:devonly,kernels,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b !Data INTEGER :: errors = 0 INTEGER,DIMENSION(1):: devtest devtest(1) = 1 !$acc enter data copyin(devtest(1:1)) !$acc kernels present(devtest(1:1)) devtest(1) = 0 !$acc end kernels !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) b = 0 !$acc data copyin(a(1:LOOPCOUNT)) !$acc kernels copyout(b(1:LOOPCOUNT)) !$acc loop DO x = 1, LOOPCOUNT b(x) = a(x) END DO !$acc end kernels !$acc end data DO x = 1, LOOPCOUNT IF (abs(a(x) - b(x)) .gt. PRECISION) THEN errors = errors + 1 END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif #ifndef T2 !T2:devonly,kernels,V:2.0-2.7 LOGICAL FUNCTION test2() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b !Data INTEGER :: errors = 0 INTEGER,DIMENSION(1):: devtest devtest(1) = 1 !$acc enter data copyin(devtest(1:1)) !$acc kernels present(devtest(1:1)) devtest(1) = 0 !$acc end kernels !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) IF (devtest(1) .eq. 1) THEN CALL RANDOM_NUMBER(a) b = 0 !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) !$acc kernels copyout(b(1:LOOPCOUNT)) !$acc loop DO x = 1, LOOPCOUNT b(x) = a(x) END DO !$acc end kernels !$acc end data DO x = 1, LOOPCOUNT IF (abs(b(x)) .gt. PRECISION) THEN errors = errors + 1 END IF END DO END IF IF (errors .eq. 0) THEN test2 = .FALSE. ELSE test2 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif #ifndef T2 LOGICAL :: test2 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif #ifndef T2 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test2() END DO IF (failed) THEN failcode = failcode + 2 ** 1 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/atomic_capture_assign_expr_eqv_x.F90
RECURSIVE FUNCTION IS_POSSIBLE(a, b, length, init) RESULT(POSSIBLE) INTEGER, INTENT(IN) :: length LOGICAL, INTENT(IN) :: init LOGICAL,DIMENSION(length), INTENT(IN) :: a LOGICAL,DIMENSION(length), INTENT(IN) :: b LOGICAL,DIMENSION(length - 1) :: passed_a LOGICAL,DIMENSION(length - 1) :: passed_b LOGICAL :: holder LOGICAL :: POSSIBLE INTEGER :: x, y IF (length .eq. 0) THEN POSSIBLE = .TRUE. RETURN END IF POSSIBLE = .FALSE. DO x = 1, length IF (b(x) .eqv. init) THEN DO y = 1, x - 1 passed_a(y) = a(y) passed_b(y) = b(y) END DO DO y = x + 1, length passed_a(y - 1) = a(y) passed_b(y - 1) = b(y) END DO holder = a(x) .eqv. init IF (IS_POSSIBLE(passed_a, passed_b, length - 1, holder)) THEN POSSIBLE = .TRUE. RETURN END IF END IF END DO END FUNCTION IS_POSSIBLE #ifndef T1 !T1:construct-independent,atomic,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators REAL(8),DIMENSION(LOOPCOUNT, 10):: randoms LOGICAL,DIMENSION(LOOPCOUNT, 10):: a, b !Data LOGICAL,DIMENSION(LOOPCOUNT):: totals, totals_comparison LOGICAL,DIMENSION(10):: passed_a, passed_b LOGICAL:: init INTEGER :: errors = 0 LOGICAL IS_POSSIBLE !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(randoms) DO x = 1, LOOPCOUNT DO y = 1, 10 IF (randoms(x, y) > .5) THEN a(x, y) = .TRUE. ELSE a(x, y) = .FALSE. END IF END DO END DO totals = .FALSE. totals_comparison = .FALSE. !$acc data copyin(a(1:LOOPCOUNT,1:10)) copy(totals(1:LOOPCOUNT)) copyout(b(1:LOOPCOUNT,1:10)) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT DO y = 1, 10 !$acc atomic capture b(x, y) = totals(x) totals(x) = a(x, y) .EQV. totals(x) !$acc end atomic END DO END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT DO y = 1, 10 totals_comparison(x) = totals_comparison(x) .EQV. a(x, y) END DO END DO DO x = 1, LOOPCOUNT DO y = 1, 10 passed_a(y) = a(x, y) passed_b(y) = b(x, y) END DO init = .FALSE. IF (IS_POSSIBLE(passed_a, passed_b, 10, init) .EQV. .FALSE.) THEN errors = errors + 1 END IF END DO DO x = 1, LOOPCOUNT IF (totals_comparison(x) .NEQV. totals(x)) THEN errors = errors + 1 WRITE(*, *) totals_comparison(x) END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/atomic_update_max_x_expr_list_end.F90
#ifndef T1 !T1:construct-independent,atomic,V:2.0-2.7 LOGICAL FUNCTION test1() IMPLICIT NONE INCLUDE "acc_testsuite.Fh" INTEGER :: x, y !Iterators REAL(8),DIMENSION(LOOPCOUNT):: a, b !Data REAL(8),DIMENSION(LOOPCOUNT/10 + 1):: totals, totals_comparison INTEGER :: errors = 0 !Initilization SEEDDIM(1) = 1 # ifdef SEED SEEDDIM(1) = SEED # endif CALL RANDOM_SEED(PUT=SEEDDIM) CALL RANDOM_NUMBER(a) CALL RANDOM_NUMBER(b) totals = 0 totals_comparison = 0 !$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) copy(totals(1:(LOOPCOUNT/10 + 1))) !$acc parallel !$acc loop DO x = 1, LOOPCOUNT !$acc atomic update totals(MOD(x, LOOPCOUNT/10 + 1) + 1) = max(totals(MOD(x, LOOPCOUNT/10 + 1) + 1), a(x), b(x)) !$acc end atomic END DO !$acc end parallel !$acc end data DO x = 1, LOOPCOUNT totals_comparison(MOD(x, LOOPCOUNT/10 + 1) + 1) = max(totals_comparison(MOD(x, LOOPCOUNT/10 + 1) + 1), a(x), b(x)) END DO DO x = 1, LOOPCOUNT/10 + 1 IF (totals_comparison(x) .NE. totals(x)) THEN errors = errors + 1 WRITE(*, *) totals_comparison(x) END IF END DO IF (errors .eq. 0) THEN test1 = .FALSE. ELSE test1 = .TRUE. END IF END #endif PROGRAM main IMPLICIT NONE INTEGER :: failcode, testrun LOGICAL :: failed INCLUDE "acc_testsuite.Fh" #ifndef T1 LOGICAL :: test1 #endif failed = .FALSE. failcode = 0 #ifndef T1 DO testrun = 1, NUM_TEST_CALLS failed = failed .or. test1() END DO IF (failed) THEN failcode = failcode + 2 ** 0 failed = .FALSE. END IF #endif CALL EXIT (failcode) END PROGRAM
./openacc-vv/serial_default_present.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:serial,data,data-region,default,V:2.6-2.7 int test1(){ int err = 0; srand(SEED); real_t * a = new real_t[n]; for (int x = 0; x < n; ++x){ a[x] = 0.0; } #pragma acc enter data copyin(a[0:n]) #pragma acc serial default(present) { #pragma acc loop for (int x = 0; x < n; ++x){ a[x] = 1.0; } } #pragma acc exit data copyout(a[0:n]) for (int x = 0; x < n; ++x){ if (fabs(a[x] - 1.0) > PRECISION){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/parallel_independent_atomic_update.c
#include "acc_testsuite.h" #ifndef T1 //T1:atomic,construct-independent,V:2.7-3.2 int test1(){ int err = 0; srand(SEED); real_t *a = (real_t *)malloc(n * sizeof(real_t)); real_t *b = (real_t *)malloc(n * sizeof(real_t)); for (int x = 0; x < n; ++x){ a[x] = rand() / (real_t)(RAND_MAX / 10); b[x] = a[x]; } #pragma acc data copy(a[0:n]) { #pragma acc parallel { #pragma acc loop independent for (int x = 0; x < n; ++x){ #pragma acc atomic update (a[x])++; } } } for (int x = 0; x < n; ++x){ if (fabs(a[x] - (b[x] + 1)) > PRECISION){ err += 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
./openacc-vv/serial_loop_reduction_multiply_vector_loop.cpp
#include "acc_testsuite.h" #ifndef T1 //T1:serial,loop,reduction,combined-constructs,V:2.6-2.7 int test1(){ int err = 0; int multiplicitive_n = 128; srand(SEED); real_t * a = new real_t[10 * multiplicitive_n]; real_t * b = new real_t[10 * multiplicitive_n]; real_t * c = new real_t[10]; real_t temp; for (int x = 0; x < 10 * multiplicitive_n; ++x){ a[x] = rand() / (real_t) RAND_MAX; b[x] = rand() / (real_t) RAND_MAX; } #pragma acc data copyin(a[0:10*multiplicitive_n], b[0:10*multiplicitive_n]) copyout(c[0:10]) { #pragma acc serial loop private(temp) for (int x = 0; x < 10; ++x){ temp = 1.0; #pragma acc loop vector reduction(*:temp) for (int y = 0; y < multiplicitive_n; ++y){ temp *= a[(x * multiplicitive_n) + y] + b[(x * multiplicitive_n) + y]; } c[x] = temp; } } for (int x = 0; x < 10; ++x){ for (int y = 0; y < multiplicitive_n; ++y){ c[x] /= a[(x * multiplicitive_n) + y] + b[(x * multiplicitive_n) + y]; } } for (int x = 0; x < 10; ++x){ if (fabs(c[x] - 1) > PRECISION * (4 * multiplicitive_n - 1)){ err = 1; } } return err; } #endif int main(){ int failcode = 0; int failed; #ifndef T1 failed = 0; for (int x = 0; x < NUM_TEST_CALLS; ++x){ failed = failed + test1(); } if (failed != 0){ failcode = failcode + (1 << 0); } #endif return failcode; }
End of preview. Expand in Data Studio

Dataset Card for "llm4vv-test"

More Information needed

Downloads last month
4