Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Tests/copy_host_if.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
! copy_host_if.F90
!
!Feature under test (OpenACC 3.4, Sections 2.6.5, 2.6.6, and 2.8. March 2026):
! The specification clarifies that the data,
! and host_data constructs may contain at most one if clause.
! These tests verify correct behavior when a single valid if clause
! is used on these constructs.
!
! Tests:
! T1 - combined constructs with single if clauses:
! Uses both data and host_data constructs within the same region,
! each containing a single if clause, verifying that multiple
! constructs can independently use valid if clauses.

#ifndef T1
!T1:syntax,data,host-data,if-clause,construct-independent,V:3.4-
LOGICAL FUNCTION test1()
USE OPENACC
IMPLICIT NONE
INCLUDE "acc_testsuite.Fh"
INTEGER :: x
INTEGER :: errors = 0
INTEGER :: host
REAL(8), DIMENSION(LOOPCOUNT) :: a, b

host = 0
SEEDDIM(1) = 1
# ifdef SEED
SEEDDIM(1) = SEED
# endif
CALL RANDOM_SEED(PUT=SEEDDIM)
CALL RANDOM_NUMBER(a)
b = 0.0

!$acc data copy(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) if(.TRUE.)
!$acc parallel loop present(a(1:LOOPCOUNT), b(1:LOOPCOUNT))
DO x = 1, LOOPCOUNT
b(x) = a(x) * 2.0
END DO
!$acc end parallel loop

!$acc host_data use_device(b) if(host .ne. 0)
!$acc end host_data
!$acc end data

DO x = 1, LOOPCOUNT
IF (abs(b(x) - (a(x) * 2.0)) .gt. PRECISION) THEN
errors = errors + 1
END IF
END DO

IF (errors .eq. 0) THEN
test1 = .FALSE.
ELSE
test1 = .TRUE.
END IF
END FUNCTION
#endif
75 changes: 75 additions & 0 deletions Tests/copy_host_if.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// copy_host_if.c
//
//Feature under test (OpenACC 3.4, Sections 2.6.5, 2.6.6, and 2.8. March 2026):
// The specification clarifies that the data,
// and host_data constructs may contain at most one if clause.
// These tests verify correct behavior when a single valid if clause
// is used on these constructs.
//
// Tests:
// T1 - combined constructs with single if clauses:
// Uses both data and host_data constructs within the same region,
// each containing a single if clause, verifying that multiple
// constructs can independently use valid if clauses.


#include "acc_testsuite.h"
#include <openacc.h>

#ifndef T1
//T1:syntax,data,host-data,if-clause,construct-independent,V:3.4-
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 host = 0;

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

#pragma acc data copy(a[0:n], b[0:n]) if(1)
{
#pragma acc parallel loop present(a[0:n], b[0:n])
for (int x = 0; x < n; ++x){
b[x] = a[x] * 2.0;
}

#pragma acc host_data use_device(b) if(host)
{
;
}
}

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

free(a);
free(b);

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 != 0){
failcode += (1 << 0);
}
#endif

return failcode;
}
74 changes: 74 additions & 0 deletions Tests/copy_host_if.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// copy_host_if.cpp
//
//Feature under test (OpenACC 3.4, Sections 2.6.5, 2.6.6, and 2.8. March 2026):
// The specification clarifies that the data,
// and host_data constructs may contain at most one if clause.
// These tests verify correct behavior when a single valid if clause
// is used on these constructs.
//
// Tests:
// T1 - combined constructs with single if clauses:
// Uses both data and host_data constructs within the same region,
// each containing a single if clause, verifying that multiple
// constructs can independently use valid if clauses.

#include "acc_testsuite.h"
#include <openacc.h>

#ifndef T1
//T1:syntax,data,host-data,if-clause,construct-independent,V:3.4-
int test1(){
int err = 0;
srand(SEED);

real_t *a = new real_t[n];
real_t *b = new real_t[n];
int host = 0;

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

#pragma acc data copy(a[0:n], b[0:n]) if(1)
{
#pragma acc parallel loop present(a[0:n], b[0:n])
for (int x = 0; x < n; ++x){
b[x] = a[x] * 2.0;
}

#pragma acc host_data use_device(b) if(host)
{
;
}
}

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

delete[] a;
delete[] b;

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 != 0){
failcode += (1 << 0);
}
#endif

return failcode;
}
56 changes: 56 additions & 0 deletions Tests/copy_if.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
! copy_if.F90
!
!Feature under test (OpenACC 3.4, Sections 2.6.5, 2.6.6, and 2.8. March 2026):
! The specification clarifies that the data,
! and host_data constructs may contain at most one if clause.
! These tests verify correct behavior when a single valid if clause
! is used on these constructs.
!
! Tests:
! T1 – data construct with single if clause:
! Uses a data region with copy and a single if(dev)
! clause controlling device execution.
!


#ifndef T1
!T1:syntax,data,if-clause,construct-independent,V:3.4-
LOGICAL FUNCTION test1()
USE OPENACC
IMPLICIT NONE
INCLUDE "acc_testsuite.Fh"
INTEGER :: x
INTEGER :: errors = 0
INTEGER :: dev
REAL(8), DIMENSION(LOOPCOUNT) :: a, b

dev = 1
SEEDDIM(1) = 1
# ifdef SEED
SEEDDIM(1) = SEED
# endif
CALL RANDOM_SEED(PUT=SEEDDIM)
CALL RANDOM_NUMBER(a)
b = 0.0

!$acc data copy(a(1:LOOPCOUNT), b(1:LOOPCOUNT)) if(dev .ne. 0)
!$acc parallel loop present(a(1:LOOPCOUNT), b(1:LOOPCOUNT))
DO x = 1, LOOPCOUNT
b(x) = a(x) * 2.0
END DO
!$acc end parallel loop
!$acc end data

DO x = 1, LOOPCOUNT
IF (abs(b(x) - (a(x) * 2.0)) .gt. PRECISION) THEN
errors = errors + 1
END IF
END DO

IF (errors .eq. 0) THEN
test1 = .FALSE.
ELSE
test1 = .TRUE.
END IF
END FUNCTION
#endif
69 changes: 69 additions & 0 deletions Tests/copy_if.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// copy_if.c
//
//Feature under test (OpenACC 3.4, Sections 2.6.5, 2.6.6, and 2.8. March 2026):
// The specification clarifies that the data,
// and host_data constructs may contain at most one if clause.
// These tests verify correct behavior when a single valid if clause
// is used on these constructs.
//
// Tests:
// T1 – data construct with single if clause:
// Uses a data region with copy and a single if(dev)
// clause controlling device execution.
//

#include "acc_testsuite.h"
#include <openacc.h>

#ifndef T1
//T1:syntax,data,if-clause,construct-independent,V:3.4-
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 dev = 1;

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

#pragma acc data copy(a[0:n], b[0:n]) if(dev)
{
#pragma acc parallel loop present(a[0:n], b[0:n])
for (int x = 0; x < n; ++x){
b[x] = a[x] * 2.0;
}
}

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

free(a);
free(b);

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 != 0){
failcode += (1 << 0);
}
#endif

return failcode;
}
Loading