42 lines · c
1// RUN: %libomp-compile-and-run2#include <stdio.h>3#include <math.h>4#include "omp_testsuite.h"5 6/* Utility function do spend some time in a loop */7int test_omp_task_imp_shared()8{9 int i;10 int k = 0;11 int result = 0;12 i=0;13 14 #pragma omp parallel15 {16 #pragma omp single17 for (k = 0; k < NUM_TASKS; k++) {18 #pragma omp task shared(i)19 {20 #pragma omp atomic21 i++;22 //this should be shared implicitly23 }24 }25 }26 result = i;27 return ((result == NUM_TASKS));28}29 30int main()31{32 int i;33 int num_failed=0;34 35 for(i = 0; i < REPETITIONS; i++) {36 if(!test_omp_task_imp_shared()) {37 num_failed++;38 }39 }40 return num_failed;41}42