diff --git a/tests/6.0/groupprivate/test_teams_groupprivate_devicetype_host.c b/tests/6.0/groupprivate/test_teams_groupprivate_devicetype_host.c new file mode 100644 index 000000000..2c6509e6f --- /dev/null +++ b/tests/6.0/groupprivate/test_teams_groupprivate_devicetype_host.c @@ -0,0 +1,44 @@ +//===--- test_groupprivate_devicetype_host.c ---------------------------===// +// +// OpenMP API Version 6.0 +// Tests the groupprivate directive ensuring proper +// behavior on the host. +// +////===----------------------------------------------------------------------===// + + +#include +#include +#include "ompvv.h" + +#define NUM_TEAMS 4 + +int group_sum; +#pragma omp groupprivate(group_sum) device_type(host) + +int test_groupprivate_devicetype_host(){ + int errors = 0; + int host_sum = 0; + int team_sum = 0; + + #pragma omp teams num_teams(NUM_TEAMS) reduction(+: team_sum) + { + group_sum = omp_get_team_num(); + + team_sum += group_sum; + + } + + for (int i = 0; i < NUM_TEAMS; i++){ + host_sum += i; + } + OMPVV_TEST_AND_SET_VERBOSE(errors, team_sum != host_sum); + return errors; +} + +int main(){ + int errors = 0; + OMPVV_TEST_AND_SET_VERBOSE(errors, test_groupprivate_devicetype_host() != 0); + OMPVV_REPORT_AND_RETURN(errors); +} + diff --git a/tests/6.0/target/test_target_teams_groupprivate.c b/tests/6.0/target/test_target_teams_groupprivate.c new file mode 100644 index 000000000..06fbc00a9 --- /dev/null +++ b/tests/6.0/target/test_target_teams_groupprivate.c @@ -0,0 +1,45 @@ +//===--- test_target_groupprivate.c -----------------------------------------===// +// +// OpenMP API Version 6.0 +// Tests the target directive with the groupprivate directive ensuring proper +// behavior. +// +////===----------------------------------------------------------------------===// + + +#include +#include +#include "ompvv.h" + +#define NUM_TEAMS 4 + +int group_sum; +#pragma omp groupprivate(group_sum) + +int test_target_groupprivate(){ + int errors = 0; + int host_sum = 0; + int team_sum = 0; + + #pragma omp target teams num_teams(NUM_TEAMS) map(tofrom: team_sum) reduction(+: team_sum) + { + group_sum = omp_get_team_num(); + + team_sum += group_sum; + + } + + for (int i = 0; i < NUM_TEAMS; i++){ + host_sum += i; + } + OMPVV_TEST_AND_SET_VERBOSE(errors, team_sum != host_sum); + return errors; +} + +int main(){ + OMPVV_TEST_OFFLOADING; + int errors = 0; + OMPVV_TEST_AND_SET_VERBOSE(errors, test_target_groupprivate() != 0); + OMPVV_REPORT_AND_RETURN(errors); +} + diff --git a/tests/6.0/target/test_target_teams_groupprivate_devicetype_any.c b/tests/6.0/target/test_target_teams_groupprivate_devicetype_any.c new file mode 100644 index 000000000..9ffa07318 --- /dev/null +++ b/tests/6.0/target/test_target_teams_groupprivate_devicetype_any.c @@ -0,0 +1,45 @@ +//===--- test_target_groupprivate_devicetype_any.c ---------------------------===// +// +// OpenMP API Version 6.0 +// Tests the target directive with the groupprivate directive ensuring proper +// behavior inside the target region with device type being any. +// +////===----------------------------------------------------------------------===// + + +#include +#include +#include "ompvv.h" + +#define NUM_TEAMS 4 + +int group_sum; +#pragma omp groupprivate(group_sum) device_type(any) + +int test_target_groupprivate_devicetype_any(){ + int errors = 0; + int host_sum = 0; + int team_sum = 0; + + #pragma omp target teams num_teams(NUM_TEAMS) map(tofrom: team_sum) reduction(+: team_sum) + { + group_sum = omp_get_team_num(); + + team_sum += group_sum; + + } + + for (int i = 0; i < NUM_TEAMS; i++){ + host_sum += i; + } + OMPVV_TEST_AND_SET_VERBOSE(errors, team_sum != host_sum); + return errors; +} + +int main(){ + OMPVV_TEST_OFFLOADING; + int errors = 0; + OMPVV_TEST_AND_SET_VERBOSE(errors, test_target_groupprivate_devicetype_any() != 0); + OMPVV_REPORT_AND_RETURN(errors); +} + diff --git a/tests/6.0/target/test_target_teams_groupprivate_devicetype_nohost.c b/tests/6.0/target/test_target_teams_groupprivate_devicetype_nohost.c new file mode 100644 index 000000000..251c41e5d --- /dev/null +++ b/tests/6.0/target/test_target_teams_groupprivate_devicetype_nohost.c @@ -0,0 +1,49 @@ +//===--- test_target_groupprivate_devicetype_nohost.c ---------------------------===// +// +// OpenMP API Version 6.0 +// Tests the target directive with the groupprivate directive ensuring proper +// behavior inside the target region with device type nohost. +// +////===----------------------------------------------------------------------===// + + +#include +#include +#include "ompvv.h" + +#define NUM_TEAMS 4 + +int group_sum; +#pragma omp groupprivate(group_sum) device_type(nohost) + +int test_target_groupprivate_devicetype_nohost(){ + int errors = 0; + int host_sum = 0; + int team_sum = 0; + + #pragma omp target teams num_teams(NUM_TEAMS) map(tofrom: team_sum, errors) reduction(+: team_sum) + + { + if (omp_get_team_num() == 0 && omp_is_initial_device()){ + errors++; + } + group_sum = omp_get_team_num(); + + team_sum += group_sum; + + } + + for (int i = 0; i < NUM_TEAMS; i++){ + host_sum += i; + } + OMPVV_TEST_AND_SET_VERBOSE(errors, team_sum != host_sum); + return errors; +} + +int main(){ + OMPVV_TEST_OFFLOADING; + int errors = 0; + OMPVV_TEST_AND_SET_VERBOSE(errors, test_target_groupprivate_devicetype_nohost() != 0); + OMPVV_REPORT_AND_RETURN(errors); +} +