8.4 (revision 624046d2)
SCOREP_User.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Score-P software (http://www.score-p.org)
3  *
4  * Copyright (c) 2009-2011,
5  * RWTH Aachen University, Germany
6  *
7  * Copyright (c) 2009-2011,
8  * Gesellschaft fuer numerische Simulation mbH Braunschweig, Germany
9  *
10  * Copyright (c) 2009-2011, 2014-2015,
11  * Technische Universitaet Dresden, Germany
12  *
13  * Copyright (c) 2009-2011,
14  * University of Oregon, Eugene, USA
15  *
16  * Copyright (c) 2009-2011, 2013-2014, 2016-2017,
17  * Forschungszentrum Juelich GmbH, Germany
18  *
19  * Copyright (c) 2009-2011, 2014-2015,
20  * German Research School for Simulation Sciences GmbH, Juelich/Aachen, Germany
21  *
22  * Copyright (c) 2009-2011,
23  * Technische Universitaet Muenchen, Germany
24  *
25  * This software may be modified and distributed under the terms of
26  * a BSD-style license. See the COPYING file in the package base
27  * directory for details.
28  *
29  */
30 
31 #ifndef SCOREP_USER_H
32 #define SCOREP_USER_H
33 
41 /* Guarded because it declares variables in every file where it is included. */
42 #ifdef SCOREP_USER_ENABLE
43 #include <scorep/SCOREP_User_Variables.h>
44 #include <scorep/SCOREP_User_Functions.h>
45 #endif
46 
47 /* Provide macro SCOREP_USER_FUNCTION_NAME that expands to the
48  * function name of the enclosing function. */
49 #ifndef SCOREP_USER_FUNCTION_NAME
50  #if defined( __cplusplus ) && defined( __FUJITSU )
51  #define SCOREP_USER_FUNCTION_NAME __FUNCTION__
52  #else
53  #define SCOREP_USER_FUNCTION_NAME __func__
54  #endif
55 #endif
56 
88 /* **************************************************************************************
89  * Documentation for region enclosing macros
90  * *************************************************************************************/
91 
523 /* **************************************************************************************
524  * Region enclosing macros
525  * *************************************************************************************/
526 /* Empty define for SCOREP_USER_FUNC_DEFINE to allow documentation of the macro and
527  let it disappear in C/C++ codes */
528 #define SCOREP_USER_FUNC_DEFINE()
529 
530 #ifdef SCOREP_USER_ENABLE
531 
532 #define SCOREP_USER_REGION_DEFINE( handle ) \
533  static SCOREP_User_RegionHandle handle = SCOREP_USER_INVALID_REGION;
534 
535 #define SCOREP_USER_REGION_ENTER( handle ) SCOREP_User_RegionEnter( handle );
536 
537 #define SCOREP_USER_REGION_BEGIN( handle, name, type ) SCOREP_User_RegionBegin( \
538  &handle, &SCOREP_User_LastFileName, &SCOREP_User_LastFileHandle, name, \
539  type, __FILE__, __LINE__ );
540 
541 #define SCOREP_USER_REGION_INIT( handle, name, type ) SCOREP_User_RegionInit( \
542  &handle, &SCOREP_User_LastFileName, &SCOREP_User_LastFileHandle, name, \
543  type, __FILE__, __LINE__ );
544 
545 #define SCOREP_USER_REGION_END( handle ) SCOREP_User_RegionEnd( handle );
546 
547 /* automatic, name tagged region begin */
548 #define SCOREP_USER_REGION_BY_NAME_BEGIN( name, type ) SCOREP_User_RegionByNameBegin( \
549  name, type, "", 0 );
550 
551 /* automatic, name tagged region end */
552 #define SCOREP_USER_REGION_BY_NAME_END( name ) SCOREP_User_RegionByNameEnd( name );
553 
554 #define SCOREP_USER_REWIND_DEFINE( handle ) \
555  static SCOREP_User_RegionHandle handle = SCOREP_USER_INVALID_REGION;
556 
557 #define SCOREP_USER_REWIND_POINT( handle, name ) \
558  SCOREP_User_RewindRegionBegin( &handle, &SCOREP_User_LastFileName, \
559  &SCOREP_User_LastFileHandle, name, \
560  SCOREP_USER_REGION_TYPE_COMMON, __FILE__, __LINE__ );
561 
562 #define SCOREP_USER_REWIND_CHECK( handle, value ) \
563  SCOREP_User_RewindRegionEnd( handle, value );
564 
565 #define SCOREP_USER_FUNC_BEGIN() static SCOREP_User_RegionHandle \
566  scorep_user_func_handle = SCOREP_USER_INVALID_REGION; \
567  SCOREP_User_RegionBegin( &scorep_user_func_handle, &SCOREP_User_LastFileName, \
568  &SCOREP_User_LastFileHandle, SCOREP_USER_FUNCTION_NAME, \
569  SCOREP_USER_REGION_TYPE_FUNCTION, __FILE__, __LINE__ );
570 
571 #define SCOREP_USER_FUNC_END() SCOREP_User_RegionEnd( scorep_user_func_handle );
572 
573 #define SCOREP_USER_GLOBAL_REGION_DEFINE( handle ) \
574  SCOREP_User_RegionHandle handle = SCOREP_USER_INVALID_REGION;
575 
576 #define SCOREP_USER_GLOBAL_REGION_EXTERNAL( handle ) \
577  extern SCOREP_User_RegionHandle handle;
578 
579 #endif // SCOREP_USER_ENABLE
580 
581 /* **************************************************************************************
582  * Documentation for Parameter macros
583  * *************************************************************************************/
584 
678 /* **************************************************************************************
679  * Parameter macros
680  * *************************************************************************************/
681 #ifdef SCOREP_USER_ENABLE
682 
683 #define SCOREP_USER_PARAMETER_INT64( name, value ) { \
684  static SCOREP_User_ParameterHandle scorep_param = SCOREP_USER_INVALID_PARAMETER; \
685  SCOREP_User_ParameterInt64( &scorep_param, name, value ); }
686 
687 #define SCOREP_USER_PARAMETER_UINT64( name, value ) { \
688  static SCOREP_User_ParameterHandle scorep_param = SCOREP_USER_INVALID_PARAMETER; \
689  SCOREP_User_ParameterUint64( &scorep_param, name, value ); }
690 
691 #define SCOREP_USER_PARAMETER_STRING( name, value ) { \
692  static SCOREP_User_ParameterHandle scorep_param = SCOREP_USER_INVALID_PARAMETER; \
693  SCOREP_User_ParameterString( &scorep_param, name, value ); }
694 
695 #endif // SCOREP_USER_ENABLE
696 
697 /* **************************************************************************************
698  * Documentation for User Metric macros
699  * *************************************************************************************/
700 
1032 /* **************************************************************************************
1033  * User Counter macros
1034  * *************************************************************************************/
1035 #ifdef SCOREP_USER_ENABLE
1036 
1037 #define SCOREP_USER_METRIC_LOCAL( metricHandle ) static SCOREP_SamplingSetHandle \
1038  metricHandle \
1039  = SCOREP_INVALID_SAMPLING_SET;
1040 
1041 #define SCOREP_USER_METRIC_GLOBAL( metricHandle ) SCOREP_SamplingSetHandle metricHandle \
1042  = SCOREP_INVALID_SAMPLING_SET;
1043 
1044 #define SCOREP_USER_METRIC_EXTERNAL( metricHandle ) \
1045  extern SCOREP_SamplingSetHandle metricHandle;
1046 
1047 #define SCOREP_USER_METRIC_INIT( metricHandle, name, unit, type, context ) \
1048  SCOREP_User_InitMetric( &metricHandle, name, unit, type, context );
1049 
1050 #define SCOREP_USER_METRIC_INT64( metricHandle, \
1051  value ) SCOREP_User_TriggerMetricInt64( \
1052  metricHandle, value );
1053 
1054 #define SCOREP_USER_METRIC_UINT64( metricHandle, \
1055  value ) SCOREP_User_TriggerMetricUint64( \
1056  metricHandle, value );
1057 
1058 #define SCOREP_USER_METRIC_DOUBLE( metricHandle, \
1059  value ) SCOREP_User_TriggerMetricDouble( \
1060  metricHandle, value );
1061 
1062 #endif // SCOREP_USER_ENABLE
1063 
1064 /* ****************************************************************************
1065 * Documentation for Topology macros
1066 * ****************************************************************************/
1067 
1165 /* **************************************************************************************
1166  * User Topology macros
1167  * *************************************************************************************/
1168 #ifdef SCOREP_USER_ENABLE
1169 
1170 #define SCOREP_USER_CARTESIAN_TOPOLOGY_CREATE( userTopology, name, nDims ) \
1171  SCOREP_User_CartesianTopologyHandle userTopology = SCOREP_USER_INVALID_CARTESIAN_TOPOLOGY; \
1172  SCOREP_User_CartTopologyCreate( &userTopology, name, nDims );
1173 
1174 #define SCOREP_USER_CARTESIAN_TOPOLOGY_ADD_DIM( userTopology, size, periodic, name ) \
1175  SCOREP_User_CartTopologyAddDim( userTopology, size, periodic, name );
1176 
1177 #define SCOREP_USER_CARTESIAN_TOPOLOGY_INIT( userTopology ) \
1178  SCOREP_User_CartTopologyInit( userTopology );
1179 
1180 #define SCOREP_USER_CARTESIAN_TOPOLOGY_SET_COORDS( userTopology, nDims, ... ) \
1181  SCOREP_User_CartTopologySetCoords( userTopology, nDims, __VA_ARGS__ );
1182 
1183 #endif // SCOREP_USER_ENABLE
1184 
1185 //just for doxygen completeness in Fortran case.
1186 #define SCOREP_USER_CARTESIAN_TOPOLOGY_DEFINE( userTopology )
1187 
1188 /* **************************************************************************************
1189  * Documentation for C++ specific macros
1190  * *************************************************************************************/
1191 
1223 /* **************************************************************************************
1224  * C++ specific macros
1225  * *************************************************************************************/
1226 #ifdef SCOREP_USER_ENABLE
1227 
1228 #ifdef __cplusplus
1229 
1230 /* We want to initialize the region handle only once and store it in a static variable.
1231  Thus, if the region is revisited, we do not need to evaluate filters and check double
1232  definitions. However, we want the region object reconstruct every time to execute
1233  the enter/exit in the constructor/destructor. The region handle in the class is
1234  necessary to pass the region handle from the constructor to the destructor. */
1235 #define SCOREP_USER_REGION( name, type ) static SCOREP_User_RegionHandle \
1236  scorep_user_region_handle = SCOREP_USER_INVALID_REGION; \
1237  SCOREP_User_RegionClass \
1238  scorep_user_region_inst( &scorep_user_region_handle, \
1239  name, \
1240  type, \
1241  &SCOREP_User_LastFileName, \
1242  &SCOREP_User_LastFileHandle, \
1243  __FILE__, __LINE__ );
1244 
1245 #else // __cplusplus
1246 
1247 #define SCOREP_USER_REGION( name, type )
1248 
1249 #endif // __cplusplus
1250 
1251 #endif // SCOREP_USER_ENABLE
1252 
1253 /* **************************************************************************************
1254  * Documentation for Control macros
1255  * *************************************************************************************/
1256 
1360 /* **************************************************************************************
1361  * Control macros
1362  * *************************************************************************************/
1363 
1364 #ifdef SCOREP_USER_ENABLE
1365 
1366 #define SCOREP_RECORDING_ON() SCOREP_User_EnableRecording();
1367 
1368 #define SCOREP_RECORDING_OFF() SCOREP_User_DisableRecording();
1369 
1370 #define SCOREP_RECORDING_IS_ON() SCOREP_User_RecordingEnabled()
1371 
1372 #else // SCOREP_USER_ENABLE
1373 
1374 /* **************************************************************************************
1375  * Empty macros, if user instrumentation is disabled
1376  * *************************************************************************************/
1377 
1378 #define SCOREP_USER_REGION( name, type )
1379 #define SCOREP_USER_REGION_DEFINE( handle )
1380 #define SCOREP_USER_REWIND_DEFINE( handle )
1381 #define SCOREP_USER_REWIND_POINT( handle, name )
1382 #define SCOREP_USER_REGION_BEGIN( handle, name, type )
1383 #define SCOREP_USER_REGION_BY_NAME_BEGIN( name, type )
1384 #define SCOREP_USER_REGION_INIT( handle, name, type )
1385 #define SCOREP_USER_REGION_END( handle )
1386 #define SCOREP_USER_REGION_BY_NAME_END( name )
1387 #define SCOREP_USER_REWIND_CHECK( handle, value )
1388 #define SCOREP_USER_REGION_ENTER( handle )
1389 #define SCOREP_USER_FUNC_BEGIN()
1390 #define SCOREP_USER_FUNC_END()
1391 #define SCOREP_USER_GLOBAL_REGION_DEFINE( handle )
1392 #define SCOREP_USER_GLOBAL_REGION_EXTERNAL( handle )
1393 #define SCOREP_USER_PARAMETER_INT64( name, value )
1394 #define SCOREP_USER_PARAMETER_UINT64( name, value )
1395 #define SCOREP_USER_PARAMETER_STRING( name, value )
1396 #define SCOREP_USER_METRIC_GLOBAL( metricHandle )
1397 #define SCOREP_USER_METRIC_EXTERNAL( metricHandle )
1398 #define SCOREP_USER_METRIC_LOCAL( metricHandle )
1399 #define SCOREP_USER_METRIC_INIT( metricHandle, name, unit, type, context )
1400 #define SCOREP_USER_METRIC_INT64( metricHandle, value )
1401 #define SCOREP_USER_METRIC_UINT64( metricHandle, value )
1402 #define SCOREP_USER_METRIC_DOUBLE( metricHandle, value )
1403 #define SCOREP_RECORDING_ON()
1404 #define SCOREP_RECORDING_OFF()
1405 #define SCOREP_RECORDING_IS_ON() 0
1406 #define SCOREP_USER_CARTESIAN_TOPOLOGY_CREATE( userTopology, name, ndims )
1407 #define SCOREP_USER_CARTESIAN_TOPOLOGY_ADD_DIM( userTopology, size, periodic, name )
1408 #define SCOREP_USER_CARTESIAN_TOPOLOGY_INIT( userTopology )
1409 #define SCOREP_USER_CARTESIAN_TOPOLOGY_SET_COORDS( userTopology, nDims, ... )
1410 
1411 #endif // SCOREP_USER_ENABLE
1412 
1415 #endif /* SCOREP_USER_H */