arraybench.c (4151B)
1 /**************************************************************************** 2 * * 3 * OpenMP MicroBenchmark Suite - Version 3.1 * 4 * * 5 * produced by * 6 * * 7 * Mark Bull, Fiona Reid and Nix Mc Donnell * 8 * * 9 * at * 10 * * 11 * Edinburgh Parallel Computing Centre * 12 * * 13 * email: markb@epcc.ed.ac.uk or fiona@epcc.ed.ac.uk * 14 * * 15 * * 16 * This version copyright (c) The University of Edinburgh, 2015. * 17 * * 18 * * 19 * Licensed under the Apache License, Version 2.0 (the "License"); * 20 * you may not use this file except in compliance with the License. * 21 * You may obtain a copy of the License at * 22 * * 23 * http://www.apache.org/licenses/LICENSE-2.0 * 24 * * 25 * Unless required by applicable law or agreed to in writing, software * 26 * distributed under the License is distributed on an "AS IS" BASIS, * 27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 28 * See the License for the specific language governing permissions and * 29 * limitations under the License. * 30 * * 31 ****************************************************************************/ 32 33 #include <stdio.h> 34 #include <stdlib.h> 35 #include <math.h> 36 #include <omp.h> 37 38 #include "common.h" 39 #include "arraybench.h" 40 41 double btest[IDA]; 42 double atest[IDA]; 43 44 #pragma omp threadprivate (btest) 45 46 int main(int argc, char **argv) { 47 48 init(argc, argv); 49 50 /* GENERATE REFERENCE TIME */ 51 reference("reference time 1", &refer); 52 53 char testName[32]; 54 55 /* TEST PRIVATE */ 56 sprintf(testName, "PRIVATE %d", IDA); 57 benchmark(testName, &testprivnew); 58 59 /* TEST FIRSTPRIVATE */ 60 sprintf(testName, "FIRSTPRIVATE %d", IDA); 61 benchmark(testName, &testfirstprivnew); 62 63 #ifdef OMPVER2 64 /* TEST COPYPRIVATE */ 65 sprintf(testName, "COPYPRIVATE %d", IDA); 66 benchmark(testName, &testcopyprivnew); 67 #endif 68 69 /* TEST THREADPRIVATE - COPYIN */ 70 sprintf(testName, "COPYIN %d", IDA); 71 benchmark(testName, &testthrprivnew); 72 73 finalise(); 74 75 return EXIT_SUCCESS; 76 77 } 78 79 void refer() { 80 int j; 81 double a[1]; 82 for (j = 0; j < innerreps; j++) { 83 array_delay(delaylength, a); 84 } 85 } 86 87 void testfirstprivnew() { 88 int j; 89 for (j = 0; j < innerreps; j++) { 90 #pragma omp parallel firstprivate(atest) 91 { 92 array_delay(delaylength, atest); 93 } 94 } 95 } 96 97 void testprivnew() { 98 int j; 99 for (j = 0; j < innerreps; j++) { 100 #pragma omp parallel private(atest) 101 { 102 array_delay(delaylength, atest); 103 } 104 } 105 } 106 107 #ifdef OMPVER2 108 void testcopyprivnew() 109 { 110 int j; 111 for (j=0; j<innerreps; j++) { 112 #pragma omp parallel private(atest) 113 { 114 #pragma omp single copyprivate(atest) 115 { 116 array_delay(delaylength, atest); 117 } 118 } 119 } 120 } 121 122 #endif 123 124 void testthrprivnew() { 125 int j; 126 for (j = 0; j < innerreps; j++) { 127 #pragma omp parallel copyin(btest) 128 { 129 array_delay(delaylength, btest); 130 } 131 } 132 133 }