- Timestamp:
- 2016-05-20T09:47:27+02:00 (8 years ago)
- Location:
- branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/Makefile
r6514 r6582 1 MPICC=mpiicc 1 #MPICC=mpiicc 2 MPICC=gcc 2 3 PAPI_INC=/users/home/opt/papi/papi-5.1.0/include/ 3 4 PAPI_LIB=/users/home/opt/papi/papi-5.1.0/lib/ 4 5 5 all: count_event.o6 ar rcs libpm.a count_event.o6 all: libperf_regions.so 7 # ar rcs libpm.a count_event.o 7 8 8 count_event.o : count_event.c 9 ${MPICC} -I${PAPI_INC} -L${PAPI_LIB} -lpapi -c count_event.c -o count_event.o 9 libperf_regions.so : count_event.o perf_region_names.o perf_regions.o 10 11 # 12 # just create object files 13 # 10 14 11 clean : 12 rm count_event.o libpm.a 15 #libperf_regions.so : count_event.o perf_region_names.o perf_regions.o 16 # ${MPICC} -I${PAPI_INC} -L${PAPI_LIB} -lpapi -c count_event.c -o count_event.o 17 # ${MPICC} -fPIC -shared -I${PAPI_INC} -L${PAPI_LIB} count_event.o perf_regions.o perf_region_names.o -o libperf_regions.so -lpapi 18 19 count_event.o: count_event.c 20 ${MPICC} -c -g -I${PAPI_INC} -L${PAPI_LIB} -c count_event.c -o count_event.o -lpapi 21 22 perf_region_names.o: perf_region_names.c 23 ${MPICC} -c -g perf_region_names.c -o perf_region_names.o 24 25 perf_regions.o: perf_regions.c 26 ${MPICC} -c -g perf_regions.c -o perf_regions.o 27 28 clean: 29 rm -f perf_regions.so 30 rm -f count_event.o 31 rm -f perf_region_names.o 32 rm -f perf_regions.o -
branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/TESTS/Makefile
r6540 r6582 1 FC= ifort1 FC=gfortran 2 2 PAPI_INC=/users/home/opt/papi/papi-5.1.0/include/ 3 3 PAPI_LIB=/users/home/opt/papi/papi-5.1.0/lib/ … … 5 5 6 6 all: 7 ${FC} -o nemo_test nemo_test.F90 -I${PAPI_INC} -L${PAPI_LIB} -lpapi -L${COUNTERS_LIB} -lpm 7 # ${FC} -I${PAPI_INC} -L${PAPI_LIB} -L${COUNTERS_LIB} -lperf_regions -o nemo_test nemo_test.F90 -lpapi 8 ${FC} -g -I${PAPI_INC} -L${PAPI_LIB} -L${COUNTERS_LIB} ../*.o -o nemo_test nemo_test.F90 -lpapi 8 9 9 10 clean : 10 11 rm nemo_test 12 -
branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/TESTS/nemo_test.F90
r6540 r6582 1 #include "../perf_region_defines.h" 2 1 3 PROGRAM nemo 2 4 3 5 interface 4 subroutine counting_init ( ) bind ( C, & 5 & name ="counting_init" ) 6 use iso_c_binding 7 end subroutine counting_init 8 9 subroutine counting_start ( ) bind ( C, & 10 & name ="counting_start" ) 11 use iso_c_binding 12 end subroutine counting_start 13 14 subroutine counting_stop ( ) bind ( C, & 15 & name ="counting_stop" ) 16 use iso_c_binding 17 end subroutine counting_stop 6 subroutine perf_regions_init ( ) bind ( C, & 7 & name ="perf_regions_init" ) 8 use iso_c_binding 9 end subroutine perf_regions_init 10 11 12 subroutine perf_regions_finalize ( ) bind ( C, & 13 & name ="perf_regions_finalize" ) 14 use iso_c_binding 15 end subroutine perf_regions_finalize 16 17 18 subroutine perf_region_start (id, measure_type) bind ( C, & 19 & name ="perf_region_start" ) 20 use iso_c_binding 21 INTEGER, VALUE, INTENT(IN) ::id 22 INTEGER, VALUE, INTENT(IN) ::measure_type 23 end subroutine perf_region_start 24 25 subroutine perf_region_stop (id) bind ( C, & 26 & name ="perf_region_stop" ) 27 use iso_c_binding 28 INTEGER, VALUE, INTENT(IN) ::id 29 end subroutine perf_region_stop 30 18 31 end interface 19 32 33 call perf_regions_init() 34 20 35 CALL test 36 CALL test 37 38 call perf_regions_finalize() 21 39 22 40 CONTAINS … … 35 53 INTEGER :: ji, jj, jk 36 54 CHARACTER(len=10) :: env 55 56 call perf_region_start (PERF_REGIONS_FOO, IOR(PERF_TIMINGS, PERF_COUNTERS)) 37 57 38 58 CALL get_environment_variable("JPI", env) … … 94 114 !*********************** 95 115 96 call counting_init()97 call counting_start ()98 116 DO jk = 1, jpk 99 117 DO jj = 1, jpj … … 239 257 END DO 240 258 END DO 241 242 call counting_stop()243 259 244 260 DEALLOCATE(mydomain) … … 260 276 DEALLOCATE(tsn) 261 277 278 call perf_region_stop(PERF_REGIONS_FOO) 279 262 280 end subroutine test 263 281 -
branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/TESTS/run_job
r6540 r6582 5 5 export JPK=72 6 6 7 # 8 # Use papi_avail command to check available performance counters 9 # These are part of papi-tools package 10 # 7 11 export NUM_COUNTERS=2 8 12 export LIST_COUNTERS=FP_COMP_OPS_EXE,PAPI_L3_TCM 9 13 14 export NUM_COUNTERS=1 15 export LIST_COUNTERS=PAPI_L3_TCM 16 10 17 ./nemo_test -
branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/count_event.c
r6514 r6582 1 1 #include <stdio.h> 2 #include <stdlib.h> 2 3 #include <string.h> 3 4 #include "papi.h" 4 5 static int retval; 6 7 static long long *values; 8 static int EventSet = PAPI_NULL; 9 static char **event; 10 static int *event_code; 11 static int numcount; 12 static char *listcount; 5 #include "count_event.h" 13 6 14 7 15 int counting_init() { 8 static long long *count_values; 9 static char **count_event; 10 static int *count_event_code; 11 static int count_numcount; 12 static char *count_listcount; 16 13 17 int i=0; 18 char *events; 14 15 /** 16 * Initialize performance counters based on environment variables 17 * 18 * TODO: add more documentation 19 */ 20 int count_init() { 19 21 20 22 if(getenv("NUM_COUNTERS")==NULL) 21 23 { 22 24 printf("NUM_COUNTERS is not defined!\n"); 23 return 1;25 exit(1); 24 26 } 25 27 else 26 28 { 27 numcount=atoi(getenv("NUM_COUNTERS"));29 count_numcount=atoi(getenv("NUM_COUNTERS")); 28 30 } 29 31 … … 31 33 { 32 34 printf("LIST_COUNTERS is not defined!\n"); 33 return 1;35 exit(1); 34 36 } 35 37 else 36 38 { 37 listcount=getenv("LIST_COUNTERS");39 count_listcount = getenv("LIST_COUNTERS"); 38 40 } 39 41 40 41 values = (long long *) malloc(numcount*sizeof(long long)); 42 event = (char **) malloc(numcount*sizeof(char*)); 43 event_code = (int *) malloc(numcount*sizeof(int)); 42 count_values = (long long *) malloc(count_numcount*sizeof(long long)); 43 count_event = (char **) malloc(count_numcount*sizeof(char*)); 44 count_event_code = (int *) malloc(count_numcount*sizeof(int)); 44 45 45 46 // PAPI init 47 int retval; 46 48 if (PAPI_is_initialized() == PAPI_NOT_INITED) { 47 49 if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) { … … 50 52 } 51 53 } 52 53 events=strtok(strdup(listcount), ","); 54 55 char *events=strtok(strdup(count_listcount), ","); 56 57 int i = 0; 54 58 while(events!=NULL) 55 59 { 56 event[i]=events;60 count_event[i]=events; 57 61 i++; 58 62 events = strtok(NULL, ","); 59 63 } 60 61 for (i =0; i<numcount;i++)64 65 for (int i=0; i < count_numcount;i++) 62 66 { 63 67 // get the PAPI event code related to a PAPI event name 64 if ((retval = PAPI_event_name_to_code( event[i], &event_code[i])) != PAPI_OK)68 if ((retval = PAPI_event_name_to_code(count_event[i], &count_event_code[i])) != PAPI_OK) 65 69 printf("PAPI_event_name_to_code failed! Line: %d File: %s - retval: %d\n", __LINE__, __FILE__, retval); 66 70 } 67 71 72 if (count_numcount > PERF_COUNTERS_MAX) 73 { 74 printf("Maximum number of performance counters (%i) reached\n", PERF_COUNTERS_MAX); 75 exit(1); 76 } 77 68 78 return 0; 69 70 79 } 71 80 72 int counting_start() {73 81 82 83 /** 84 * start performance counting. Existing performance counters are overwritten! (TODO: Check this) 85 */ 86 int count_start() { 74 87 // start the event 75 if (PAPI_start_counters( event_code,numcount) != PAPI_OK) {88 if (PAPI_start_counters(count_event_code,count_numcount) != PAPI_OK) { 76 89 PAPI_perror("PAPI_start\n"); 77 90 } … … 81 94 } 82 95 83 int counting_stop() {84 96 85 int i; 86 97 /** 98 * stop performance counters and store everything to array values 99 */ 100 int count_stop() { 87 101 // stop the event 88 if ( PAPI_stop_counters( values,numcount) != PAPI_OK ) {102 if ( PAPI_stop_counters(count_values, count_numcount) != PAPI_OK ) { 89 103 PAPI_perror("PAPI_stop\n"); 90 104 return 0; 91 105 } 92 106 93 for (i=0; i<numcount; i++) 94 { 95 printf("%s: %lld\n", event[i], values[i]); 96 } 107 // for (int i=0; i<count_numcount; i++) 108 // { 109 // printf("COUNT_STOP_OUTPUT: %s: %lld\n", count_event[i], count_values[i]); 110 // } 111 } 97 112 98 free(values); 99 free(event); 100 free(event_code); 113 /** 114 * shutdown performance counters 115 */ 116 int count_finalize() 117 { 118 free(count_values); 119 free(count_event); 120 free(count_event_code); 101 121 102 122 return 0; 103 104 123 } 105 124 125 126 /** 127 * return pointer to array of counter values 128 */ 129 long long *count_get_valueptr() 130 { 131 return count_values; 132 } 133 134 135 136 /** 137 * return pointer to array of event names 138 */ 139 char **count_get_event_names() 140 { 141 return count_event; 142 } 143 144 /** 145 * return number of performance counters 146 */ 147 int count_get_num() 148 { 149 return count_numcount; 150 }
Note: See TracChangeset
for help on using the changeset viewer.