New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 6582 – NEMO

Changeset 6582


Ignore:
Timestamp:
2016-05-20T09:47:27+02:00 (8 years ago)
Author:
timgraham
Message:

Commit Martin's changes to COUNTERS tool including a new timing/performance module that does not use string comparisons.

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 
     2MPICC=gcc 
    23PAPI_INC=/users/home/opt/papi/papi-5.1.0/include/ 
    34PAPI_LIB=/users/home/opt/papi/papi-5.1.0/lib/ 
    45 
    5 all: count_event.o 
    6    ar rcs libpm.a count_event.o 
     6all: libperf_regions.so 
     7#  ar rcs libpm.a count_event.o 
    78 
    8 count_event.o : count_event.c 
    9    ${MPICC} -I${PAPI_INC} -L${PAPI_LIB} -lpapi -c count_event.c -o count_event.o 
     9libperf_regions.so : count_event.o perf_region_names.o perf_regions.o 
     10    
     11# 
     12# just create object files 
     13# 
    1014 
    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 
     19count_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    
     22perf_region_names.o: perf_region_names.c 
     23   ${MPICC} -c -g perf_region_names.c -o perf_region_names.o 
     24 
     25perf_regions.o: perf_regions.c 
     26   ${MPICC} -c -g perf_regions.c -o perf_regions.o 
     27 
     28clean: 
     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=ifort 
     1FC=gfortran 
    22PAPI_INC=/users/home/opt/papi/papi-5.1.0/include/ 
    33PAPI_LIB=/users/home/opt/papi/papi-5.1.0/lib/ 
     
    55 
    66all: 
    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 
    89 
    910clean : 
    1011   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 
    13PROGRAM nemo 
    24 
    35     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 
    1831      end interface 
    1932 
     33     call perf_regions_init() 
     34 
    2035     CALL test 
     36     CALL test 
     37 
     38     call perf_regions_finalize() 
    2139 
    2240CONTAINS 
     
    3553   INTEGER                                   :: ji, jj, jk 
    3654   CHARACTER(len=10)                         :: env 
     55 
     56   call perf_region_start (PERF_REGIONS_FOO,  IOR(PERF_TIMINGS, PERF_COUNTERS)) 
    3757 
    3858   CALL get_environment_variable("JPI", env) 
     
    94114!*********************** 
    95115 
    96    call counting_init() 
    97    call counting_start () 
    98116   DO jk = 1, jpk 
    99117     DO jj = 1, jpj 
     
    239257       END DO 
    240258     END DO 
    241     
    242      call counting_stop() 
    243259 
    244260     DEALLOCATE(mydomain) 
     
    260276     DEALLOCATE(tsn) 
    261277 
     278     call perf_region_stop(PERF_REGIONS_FOO) 
     279 
    262280     end subroutine test 
    263281 
  • branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/TESTS/run_job

    r6540 r6582  
    55export JPK=72 
    66 
     7# 
     8# Use papi_avail command to check available performance counters 
     9# These are part of papi-tools package 
     10# 
    711export NUM_COUNTERS=2 
    812export LIST_COUNTERS=FP_COMP_OPS_EXE,PAPI_L3_TCM 
    913 
     14export NUM_COUNTERS=1 
     15export LIST_COUNTERS=PAPI_L3_TCM 
     16 
    1017./nemo_test 
  • branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/TOOLS/COUNTERS/count_event.c

    r6514 r6582  
    11#include <stdio.h> 
     2#include <stdlib.h> 
    23#include <string.h> 
    34#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" 
    136 
    147 
    15 int counting_init() { 
     8static long long *count_values; 
     9static char **count_event; 
     10static int *count_event_code; 
     11static int count_numcount; 
     12static char *count_listcount; 
    1613 
    17   int i=0; 
    18   char *events; 
     14 
     15/** 
     16 * Initialize performance counters based on environment variables 
     17 * 
     18 * TODO: add more documentation 
     19 */ 
     20int count_init() { 
    1921 
    2022  if(getenv("NUM_COUNTERS")==NULL) 
    2123  { 
    2224    printf("NUM_COUNTERS is not defined!\n"); 
    23     return 1; 
     25    exit(1); 
    2426  } 
    2527  else 
    2628  { 
    27     numcount=atoi(getenv("NUM_COUNTERS")); 
     29    count_numcount=atoi(getenv("NUM_COUNTERS")); 
    2830  } 
    2931 
     
    3133  { 
    3234    printf("LIST_COUNTERS is not defined!\n"); 
    33     return 1; 
     35    exit(1); 
    3436  } 
    3537  else 
    3638  { 
    37     listcount=getenv("LIST_COUNTERS"); 
     39    count_listcount = getenv("LIST_COUNTERS"); 
    3840  } 
    3941 
    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)); 
    4445 
    4546  // PAPI init 
     47  int retval; 
    4648  if (PAPI_is_initialized() == PAPI_NOT_INITED) { 
    4749    if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) { 
     
    5052    } 
    5153  } 
    52    
    53   events=strtok(strdup(listcount), ","); 
     54  
     55  char *events=strtok(strdup(count_listcount), ","); 
     56 
     57  int i = 0; 
    5458  while(events!=NULL) 
    5559  { 
    56     event[i]=events; 
     60    count_event[i]=events; 
    5761    i++; 
    5862    events = strtok(NULL, ","); 
    5963  } 
    60    
    61   for (i=0; i<numcount;i++) 
     64 
     65  for (int i=0; i < count_numcount;i++) 
    6266  { 
    6367    // 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) 
    6569      printf("PAPI_event_name_to_code failed! Line: %d File: %s - retval: %d\n", __LINE__, __FILE__, retval); 
    6670  } 
    6771 
     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 
    6878  return 0; 
    69  
    7079} 
    7180 
    72 int counting_start() { 
    7381 
     82 
     83/** 
     84 * start performance counting. Existing performance counters are overwritten! (TODO: Check this) 
     85 */ 
     86int count_start() { 
    7487  // 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) { 
    7689    PAPI_perror("PAPI_start\n"); 
    7790  }  
     
    8194} 
    8295 
    83 int counting_stop() { 
    8496 
    85    int i; 
    86  
     97/**  
     98 * stop performance counters and store everything to array values 
     99 */ 
     100int count_stop() { 
    87101   // stop the event 
    88    if ( PAPI_stop_counters(values,numcount) != PAPI_OK ) { 
     102   if ( PAPI_stop_counters(count_values, count_numcount) != PAPI_OK ) { 
    89103      PAPI_perror("PAPI_stop\n"); 
    90104      return 0; 
    91105    }  
    92106 
    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} 
    97112 
    98     free(values); 
    99     free(event); 
    100     free(event_code); 
     113/** 
     114 * shutdown performance counters 
     115 */ 
     116int count_finalize() 
     117{ 
     118    free(count_values); 
     119    free(count_event); 
     120    free(count_event_code); 
    101121 
    102122    return 0; 
    103  
    104123} 
    105124 
     125 
     126/** 
     127 * return pointer to array of counter values 
     128 */ 
     129long long *count_get_valueptr() 
     130{ 
     131    return count_values; 
     132} 
     133 
     134 
     135 
     136/** 
     137 * return pointer to array of event names 
     138 */ 
     139char **count_get_event_names() 
     140{ 
     141    return count_event; 
     142} 
     143 
     144/** 
     145 * return number of performance counters 
     146 */ 
     147int count_get_num() 
     148{ 
     149    return count_numcount; 
     150} 
Note: See TracChangeset for help on using the changeset viewer.