Skip to content

Commit

Permalink
More changes for HPX support
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Jul 24, 2020
1 parent 7ac9c4f commit f61a4df
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
17 changes: 11 additions & 6 deletions cmake/Modules/APEX_SetupCUPTI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ if(APEX_WITH_CUDA)

# Add an imported target
add_library(cuda INTERFACE IMPORTED)
add_library(${CUDA_cupti_LIBRARY} INTERFACE IMPORTED)
add_library(cupti INTERFACE IMPORTED)
hpx_info("apex" "Building APEX with CUDA/CUPTI support.")
set_property(TARGET cupti PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${CUDAToolkit_INCLUDE_DIR})
#set_property(TARGET cuda PROPERTY
#INTERFACE_LINK_LIBRARIES ${CUDA_LIBRARY})
#set_property(TARGET cupti PROPERTY
#INTERFACE_LINK_LIBRARIES ${CUDA_cupti_LIBRARY})
set_property(TARGET cuda PROPERTY
INTERFACE_LINK_LIBRARIES ${CUDA_LIBRARY})
set_property(TARGET cupti PROPERTY
INTERFACE_LINK_LIBRARIES ${CUDA_cupti_LIBRARY})

# Add the right definitions to the apex_flags target
target_compile_definitions(apex_flags INTERFACE APEX_WITH_CUDA)

list(APPEND _apex_imported_targets cuda cupti)
list(APPEND _apex_imported_targets cuda)
list(APPEND _apex_imported_targets cupti)

else()
add_custom_target(project_cuda)
Expand Down
15 changes: 8 additions & 7 deletions src/apex/CMakeLists.hpx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ else()
set(APEX_ARCH_X86 FALSE)
endif()

if(APEX_USE_CUDA)
enable_language(CUDA)
include(APEX_SetupCUPTI)
set(cupti_sources activity_trace_async.cpp)
include_directories (${CUDAToolkit_INCLUDE_DIR})
endif(APEX_USE_CUDA)

# If not x86, don't use RDTSC
if(NOT APEX_ARCH_X86)
target_compile_definitions(apex_flags INTERFACE APEX_USE_CLOCK_TIMESTAMP=1)
Expand Down Expand Up @@ -175,6 +168,12 @@ endif()
# We create one target per imported library (cleaner) #
set(_apex_imported_targets "")

include(APEX_SetupCUPTI)
if(APEX_WITH_CUDA)
set(cupti_sources activity_trace_async.cpp)
#include_directories (${CUDAToolkit_INCLUDE_DIR})
endif(APEX_WITH_CUDA)

# Setup PAPI
include(APEX_SetupPAPI)

Expand Down Expand Up @@ -343,8 +342,10 @@ target_include_directories(apex PUBLIC
target_link_libraries(apex PRIVATE apex_flags)

# Link to all imported targets
hpx_info("apex" "Will build APEX with imported targets:")
foreach(lib IN LISTS _apex_imported_targets)
if (TARGET "${lib}")
hpx_info("apex" " ${lib}")
target_link_libraries(apex PRIVATE ${lib})
endif()
endforeach()
Expand Down
8 changes: 4 additions & 4 deletions src/apex/CMakeLists.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ if (OTF2_FOUND)
SET(OTF2_SOURCE otf2_listener.cpp)
endif(OTF2_FOUND)

if (APEX_USE_CUDA)
if (APEX_WITH_CUDA)
SET(CUPTI_SOURCE activity_trace_async.cpp)
endif(APEX_USE_CUDA)
endif(APEX_WITH_CUDA)

# Try to keep this in alphabetical order
SET(all_SOURCE
Expand Down Expand Up @@ -80,9 +80,9 @@ if (MPI_CXX_FOUND)
include_directories (${MPI_CXX_INCLUDE_PATH})
endif(MPI_CXX_FOUND)

if (APEX_USE_CUDA)
if (APEX_WITH_CUDA)
include_directories (${CUDAToolkit_INCLUDE_DIR})
endif(APEX_USE_CUDA)
endif(APEX_WITH_CUDA)

# If we are building libapex.so, we want to include all the other libraries,
# so that we can LD_PRELOAD this library with all requirements met.
Expand Down
2 changes: 1 addition & 1 deletion src/apex/apex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ void flushTrace(void);

void finalize()
{
#ifdef APEX_USE_CUDA
#ifdef APEX_WITH_CUDA
flushTrace();
#endif
#ifdef APEX_WITH_JUPYTER_SUPPORT
Expand Down
6 changes: 3 additions & 3 deletions src/apex/profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class disabled_profiler_exception : public std::exception {
}
};

#if !defined(APEX_USE_CLOCK_TIMESTAMP) && !defined(APEX_USE_CUDA)
#if !defined(APEX_USE_CLOCK_TIMESTAMP) && !defined(APEX_WITH_CUDA)
template<std::intmax_t clock_freq>
struct rdtsc_clock {
typedef unsigned long long rep;
Expand All @@ -62,7 +62,7 @@ struct rdtsc_clock {
};
#endif

#if defined(APEX_USE_CLOCK_TIMESTAMP) || defined(APEX_USE_CUDA)
#if defined(APEX_USE_CLOCK_TIMESTAMP) || defined(APEX_WITH_CUDA)
#define MYCLOCK std::chrono::CLOCK_TYPE
#else
typedef rdtsc_clock<1> OneHzClock;
Expand Down Expand Up @@ -215,7 +215,7 @@ class profiler {

/* This function returns 1/X, where "X" is the MHz rating of the CPU. */
static double get_cpu_mhz () {
#if defined(APEX_USE_CLOCK_TIMESTAMP) || defined (APEX_USE_CUDA)
#if defined(APEX_USE_CLOCK_TIMESTAMP) || defined (APEX_WITH_CUDA)
return 1.0;
#else
static double ticks_per_period = 0.0;
Expand Down

0 comments on commit f61a4df

Please sign in to comment.