Ignore:
Timestamp:
01/20/18 18:46:10 (6 years ago)
Author:
dubos
Message:

devel/unstructured : OpenMP fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/src/unstructured/data_unstructured.F90

    r663 r665  
    5858  !----------------------------      PROFILING      -------------------------- 
    5959   
    60   SUBROUTINE init_trace() 
     60  SUBROUTINE init_trace() BINDC(init_trace) 
     61    !$OMP MASTER 
    6162    time_spent(:)=0. 
    6263    bytes(:)=0 
    6364    nb_calls(:)=0 
     65    !$OMP END MASTER 
    6466  END SUBROUTINE init_trace 
    6567 
     
    6769    INTEGER :: id 
    6870    DBL :: total_spent 
     71    !$OMP MASTER 
    6972    total_spent=SUM(time_spent) 
    70     PRINT *, '========================= Performance metrics =========================' 
    71     PRINT *, 'Total time spent in instrumented code (seconds) :', total_spent 
    72     PRINT *, 'Name, #calls, %time, microsec/call, MB/sec'     
    73     DO id=1,nb_routines 
    74        IF(nb_calls(id)>0) PRINT *, id_name(id), nb_calls(id), INT(100.*time_spent(id)/total_spent), & 
    75             INT(1e6*time_spent(id)/nb_calls(id)), INT(1e-6*bytes(id)/time_spent(id)) 
    76     END DO 
    77     CALL init_trace() 
     73    IF(total_spent>.01) THEN 
     74       PRINT *, '========================= Performance metrics =========================' 
     75       PRINT *, 'Total time spent in instrumented code (seconds) :', total_spent 
     76       PRINT *, 'Name, #calls, %time, microsec/call, MB/sec'     
     77       DO id=1,nb_routines 
     78          IF(nb_calls(id)>0) PRINT *, id_name(id), nb_calls(id), INT(100.*time_spent(id)/total_spent), & 
     79               INT(1e6*time_spent(id)/nb_calls(id)), INT(1e-6*bytes(id)/time_spent(id)) 
     80       END DO 
     81       CALL init_trace() 
     82    END IF 
     83    !$OMP END MASTER 
    7884  END SUBROUTINE print_trace 
    7985 
    8086  SUBROUTINE enter_trace(id, nbytes) 
    8187    INTEGER :: id, nbytes 
     88    !$OMP MASTER 
    8289    current_id = id 
    8390    bytes(id) = bytes(id) + nbytes 
    8491    nb_calls(id)=nb_calls(id)+1 
    8592    start_time = OMP_GET_WTIME() 
     93    !$OMP END MASTER 
    8694  END SUBROUTINE enter_trace 
    8795 
    8896  SUBROUTINE exit_trace() 
    8997    DBL :: elapsed 
     98    !$OMP MASTER 
    9099    elapsed = OMP_GET_WTIME()-start_time 
    91100    IF(elapsed<0.) elapsed=0. 
    92101    time_spent(current_id) = time_spent(current_id) + elapsed 
     102    !$OMP END MASTER 
    93103  END SUBROUTINE exit_trace 
    94104 
Note: See TracChangeset for help on using the changeset viewer.