diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 32fb90bcfa..41017b4a6c 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -80,8 +80,10 @@ else cd "${source_dir}/lib" git clone https://github.com/icl-utk-edu/papi.git cd papi/src - ./configure --prefix=${source_dir}/lib/papi/install - make && make install + export PAPI_BUILD=${build_dir}/papi + mkdir -p "$PAPI_BUILD" + CC="${CC:-cc}" F77="${F77:-gfortran}" ./configure --prefix=${PAPI_BUILD}/install + make -j ${dashj} && make install fi if test "${VT_ZOLTAN_ENABLED:-0}" -eq 1 @@ -132,6 +134,7 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \ -DCMAKE_C_COMPILER="${CC:-cc}" \ -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS:-}" \ -Dcheckpoint_ROOT="$CHECKPOINT_BUILD/install" \ + -Dpapi_ROOT="${build_dir}/papi/install" \ -DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH:-}" \ -DCMAKE_INSTALL_PREFIX="$VT_BUILD/install" \ -Dvt_ci_build="${VT_CI_BUILD:-0}" \ diff --git a/cmake/FindPAPI.cmake b/cmake/FindPAPI.cmake index 6ccab46b3c..66d652b4b9 100644 --- a/cmake/FindPAPI.cmake +++ b/cmake/FindPAPI.cmake @@ -1,11 +1,11 @@ # Set minimum CMake version cmake_minimum_required(VERSION 3.23 FATAL_ERROR) -set(PAPI_ROOT "${CMAKE_SOURCE_DIR}/lib/papi/install") # Find the PAPI include directory and library -find_path(PAPI_INCLUDE_DIR NAMES papi.h HINTS ${PAPI_ROOT}/include) -find_library(PAPI_LIBRARY NAMES papi HINTS ${PAPI_ROOT}/lib) +message(STATUS "Finding PAPI, PAPI_BUILD_ROOT: ${papi_ROOT}") +find_path(PAPI_INCLUDE_DIR NAMES papi.h HINTS ${papi_ROOT}/include) +find_library(PAPI_LIBRARY NAMES papi HINTS ${papi_ROOT}/lib) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PAPI DEFAULT_MSG PAPI_LIBRARY PAPI_INCLUDE_DIR) diff --git a/cmake/link_vt.cmake b/cmake/link_vt.cmake index 26d25b8298..4cc16e79a4 100644 --- a/cmake/link_vt.cmake +++ b/cmake/link_vt.cmake @@ -216,9 +216,14 @@ function(link_target_with_vt) if (${ARG_DEBUG_LINK}) message(STATUS "link_target_with_vt: papi=${ARG_LINK_PAPI}") endif() + message(STATUS "target_link_libraries: ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${PAPI_LIBRARY}") + message(STATUS "target_include_directories: ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${PAPI_INCLUDE_DIR}") target_link_libraries( ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${PAPI_LIBRARY} ) + target_include_directories( + ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${PAPI_INCLUDE_DIR} + ) endif() if (${vt_mimalloc_enabled}) diff --git a/src/vt/context/runnable_context/lb_data.cc b/src/vt/context/runnable_context/lb_data.cc index 3789aff5d4..a41f00dc5d 100644 --- a/src/vt/context/runnable_context/lb_data.cc +++ b/src/vt/context/runnable_context/lb_data.cc @@ -55,9 +55,9 @@ void LBData::start(TimeType time) { /* -- PAPI START -- */ /* Start counting events in the Event Set */ - // papi_retval_ = PAPI_start(EventSet_); - // if (papi_retval_ != PAPI_OK) - // handle_papi_error(papi_retval_, "LBData start: Starting counting events in the Event Set: "); + papi_retval_ = PAPI_start(EventSet_); + if (papi_retval_ != PAPI_OK) + handle_papi_error(papi_retval_, "LBData start: Starting counting events in the Event Set: "); /* Gets the starting time in clock cycles */ start_cycles_ = PAPI_get_real_cyc(); @@ -77,16 +77,16 @@ void LBData::finish(TimeType time) { /* -- PAPI READ AND STOP -- */ /* Read the counting events in the Event Set */ - // papi_retval_ = PAPI_read(EventSet_, papi_values_); - // if (papi_retval_ != PAPI_OK) - // handle_papi_error(papi_retval_, "LBData finish: Reading the counting events in the Event Set: "); + papi_retval_ = PAPI_read(EventSet_, papi_values_); + if (papi_retval_ != PAPI_OK) + handle_papi_error(papi_retval_, "LBData finish: Reading the counting events in the Event Set: "); - // printf("Counters after LBData::finish: %lld\n",papi_values_[0]); + printf("Counters after LBData::finish: %lld\n",papi_values_[0]); - // /* Stop the counting of events in the Event Set */ - // papi_retval_ = PAPI_stop(EventSet_, papi_values_); - // if (papi_retval_ != PAPI_OK) - // handle_papi_error(papi_retval_, "LBData finish: Stoping the counting of events in the Event Set: "); + /* Stop the counting of events in the Event Set */ + papi_retval_ = PAPI_stop(EventSet_, papi_values_); + if (papi_retval_ != PAPI_OK) + handle_papi_error(papi_retval_, "LBData finish: Stoping the counting of events in the Event Set: "); /* Gets the ending time in clock cycles */ end_cycles_ = PAPI_get_real_cyc(); diff --git a/src/vt/context/runnable_context/lb_data.h b/src/vt/context/runnable_context/lb_data.h index e6dee01fab..7d06d03fbf 100644 --- a/src/vt/context/runnable_context/lb_data.h +++ b/src/vt/context/runnable_context/lb_data.h @@ -90,13 +90,25 @@ struct LBData { { /* Create the PAPI Event Set */ papi_retval_ = PAPI_create_eventset(&EventSet_); - if (papi_retval_ != PAPI_OK) - handle_papi_error(papi_retval_, "LBData Constructor 2: Creating the PAPI Event Set: "); - - // /* Add Total Instructions Executed to the PAPI Event Set */ - // papi_retval_ = PAPI_add_event(EventSet_, PAPI_DP_OPS); - // if (papi_retval_ != PAPI_OK) - // handle_papi_error(papi_retval_, "LBData Constructor 2: Adding Total Instructions Executed to the PAPI Event Set: "); + if (papi_retval_ != PAPI_OK) { + printf("LBData Constructor 2: Creating the PAPI Event Set: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); + exit(1); + } + + int native = 0x0; + + /* Add event */ + papi_retval_ = PAPI_event_name_to_code("fp_arith_inst_retired.scalar_double", &native); + if (papi_retval_ != PAPI_OK) { + printf("LBData Constructor 2: Couldn't event_name_to_code for fp_arith_inst_retired.scalar_double: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); + exit(1); + } + /* Add it to the PAPI Event Set */ + papi_retval_ = PAPI_add_event(EventSet_, native); + if (papi_retval_ != PAPI_OK) { + printf("LBData Constructor 2: Couldn't add fp_arith_inst_retired.scalar_double to the PAPI Event Set: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); + exit(1); + } } /** diff --git a/src/vt/context/runnable_context/lb_data.impl.h b/src/vt/context/runnable_context/lb_data.impl.h index 8897d84913..69c47b03dc 100644 --- a/src/vt/context/runnable_context/lb_data.impl.h +++ b/src/vt/context/runnable_context/lb_data.impl.h @@ -63,19 +63,27 @@ LBData::LBData(ElmT* in_elm, MsgT* msg) // record the communication LB data right away! theCollection()->recordLBData(in_elm, msg); - // /* Create the PAPI Event Set */ - // papi_retval_ = PAPI_create_eventset(&EventSet_); - // if (papi_retval_ != PAPI_OK) { - // printf("LBData Constructor 1: Creating the PAPI Event Set: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); - // exit(1); - // } + /* Create the PAPI Event Set */ + papi_retval_ = PAPI_create_eventset(&EventSet_); + if (papi_retval_ != PAPI_OK) { + printf("LBData Constructor 1: Creating the PAPI Event Set: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); + exit(1); + } - // /* Add Total Instructions Executed to the PAPI Event Set */ - // papi_retval_ = PAPI_add_event(EventSet_, PAPI_TOT_INS); - // if (papi_retval_ != PAPI_OK) { - // printf("LBData Constructor 1: Adding Total Instructions Executed to the PAPI Event Set: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); - // exit(1); - // } + int native = 0x0; + + /* Add event */ + papi_retval_ = PAPI_event_name_to_code("fp_arith_inst_retired.scalar_double", &native); + if (papi_retval_ != PAPI_OK) { + printf("LBData Constructor 1: Couldn't event_name_to_code for fp_arith_inst_retired.scalar_double: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); + exit(1); + } + /* Add it to the PAPI Event Set */ + papi_retval_ = PAPI_add_event(EventSet_, native); + if (papi_retval_ != PAPI_OK) { + printf("LBData Constructor 1: Couldn't add fp_arith_inst_retired.scalar_double to the PAPI Event Set: PAPI error %d: %s\n", papi_retval_, PAPI_strerror(papi_retval_)); + exit(1); + } } }} /* end namespace vt::ctx */