Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New test for groupprivate 6.0 #842

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
44 changes: 44 additions & 0 deletions tests/6.0/groupprivate/test_teams_groupprivate_devicetype_host.c
Original file line number Diff line number Diff line change
@@ -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 <omp.h>
#include <stdio.h>
#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);
}

45 changes: 45 additions & 0 deletions tests/6.0/target/test_target_teams_groupprivate.c
Original file line number Diff line number Diff line change
@@ -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 <omp.h>
#include <stdio.h>
#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++){
rjenaa marked this conversation as resolved.
Show resolved Hide resolved
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);
}

45 changes: 45 additions & 0 deletions tests/6.0/target/test_target_teams_groupprivate_devicetype_any.c
Original file line number Diff line number Diff line change
@@ -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 <omp.h>
#include <stdio.h>
#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);
}

Original file line number Diff line number Diff line change
@@ -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 <omp.h>
#include <stdio.h>
#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);
}