Skip to content

Commit

Permalink
Adding MPI OTF2 test to make sure event unification works correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Jan 21, 2020
1 parent b3538b5 commit 5ecde67
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
26 changes: 26 additions & 0 deletions src/unit_tests/C++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,29 @@ endif (OPENMP_FOUND)
#target_link_libraries (apex_fibonacci_std_async_cpp apex_pthread_wrapper)
#add_dependencies (apex_fibonacci_std_async_cpp apex_pthread_wrapper)




# Make sure the compiler can find include files from our Apex library.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_COMPILE_FLAGS}")
include_directories (. ${APEX_SOURCE_DIR}/src/apex ${MPI_CXX_INCLUDE_PATH})

# Make sure the linker can find the Apex library once it is built.
link_directories (${APEX_BINARY_DIR}/src/apex)

# Add executable called "apex_hpx_annotated_functions_mpi" that is built from the source file
# "apex_hpx_annotated_functions.cpp". The extensions are automatically found.
add_executable (apex_hpx_annotated_functions_mpi apex_hpx_annotated_functions.cpp)
add_dependencies (apex_hpx_annotated_functions_mpi apex)
add_dependencies (examples apex_hpx_annotated_functions_mpi)

# Link the executable to the Apex library.
target_link_libraries (apex_hpx_annotated_functions_mpi apex ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m)
if (BUILD_STATIC_EXECUTABLES)
set_target_properties(apex_hpx_annotated_functions_mpi PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1)
endif()

INSTALL(TARGETS apex_hpx_annotated_functions_mpi
RUNTIME DESTINATION bin OPTIONAL
)

22 changes: 20 additions & 2 deletions src/unit_tests/C++/apex_hpx_annotated_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
#include <time.h>
#include <stdint.h>
#include "apex_api.hpp"
#if defined(APEX_HAVE_MPI)
#include <mpi.h>
#endif

uint32_t test_numthreads = 0;
int threads_per_core = 8;
__thread uint64_t guid = 0;
const int num_iterations = 10;
int comm_rank = 0;
int comm_size = 1;

#ifdef DEBUG
#ifdef DEBUG__
#define __DEBUG_PRINT__ 1
#endif

Expand Down Expand Up @@ -50,7 +55,9 @@ static void init_guid(int tid) {

void innerLoop(int *tid) {
std::shared_ptr<apex::task_wrapper> tt_ptr = apex::new_task(__func__);
apex::update_task(tt_ptr, "foo");

const char * new_label = ((comm_rank % 2 == 0) ? "foo" : "bar");
apex::update_task(tt_ptr, new_label);
apex::start(tt_ptr);

/* do some computation */
Expand Down Expand Up @@ -90,7 +97,15 @@ void* someThread(void* tmp)

int main (int argc, char** argv) {
/* initialize APEX */
#if defined(APEX_HAVE_MPI)
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
std::cout << "APP: rank " << comm_rank << " of " << comm_size << std::endl;
apex::init("apex::start unit test", comm_rank, comm_size);
#else
apex::init("apex::start unit test", 0, 1);
#endif
/* important, to make sure we get correct profiles at the end */
apex::apex_options::use_screen_output(true);
/* start a timer */
Expand Down Expand Up @@ -134,6 +149,9 @@ int main (int argc, char** argv) {
}
}
apex::cleanup();
#if defined(APEX_HAVE_MPI)
MPI_Finalize();
#endif
return 0;
}

0 comments on commit 5ecde67

Please sign in to comment.