Skip to content

Commit

Permalink
#2302: Fix PAPI build and link process; add native floating point eve…
Browse files Browse the repository at this point in the history
…nt to count
  • Loading branch information
pierrepebay committed Jul 1, 2024
1 parent bab57b7 commit c8df604
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 35 deletions.
7 changes: 5 additions & 2 deletions ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 85 in ci/build_cpp.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ci/build_cpp.sh#L85

Double quote to prevent globbing and word splitting.
make -j ${dashj} && make install

Check warning on line 86 in ci/build_cpp.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ci/build_cpp.sh#L86

Double quote to prevent globbing and word splitting.
fi

if test "${VT_ZOLTAN_ENABLED:-0}" -eq 1
Expand Down Expand Up @@ -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}" \
Expand Down
6 changes: 3 additions & 3 deletions cmake/FindPAPI.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 5 additions & 0 deletions cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
22 changes: 11 additions & 11 deletions src/vt/context/runnable_context/lb_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
26 changes: 19 additions & 7 deletions src/vt/context/runnable_context/lb_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down
32 changes: 20 additions & 12 deletions src/vt/context/runnable_context/lb_data.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit c8df604

Please sign in to comment.