Skip to content

Commit 5e8e6c7

Browse files
authored
Fix tau service compilation, move it to mpi dir (LLNL#178)
1 parent 6821373 commit 5e8e6c7

File tree

9 files changed

+60
-40
lines changed

9 files changed

+60
-40
lines changed

CMakeLists.txt

+17-12
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,6 @@ if(WITH_CUPTI)
109109
endif()
110110
endif()
111111

112-
if(WITH_TAU)
113-
find_package(TAU QUIET)
114-
if (TAU_FOUND)
115-
set(CALIPER_HAVE_TAU TRUE)
116-
set(CALIPER_TAU_CMAKE_MSG "Yes, using ${TAU_LIBRARIES}")
117-
list(APPEND CALIPER_EXTERNAL_LIBS ${TAU_LIBRARIES})
118-
else()
119-
message(WARNING "TAU bindings requested but TAU API was not found!\n"
120-
"Set TAU_PREFIX to installation path and re-run cmake.")
121-
endif()
122-
endif()
123-
124112
# Find PAPI
125113
if (WITH_PAPI)
126114
include(FindPAPI)
@@ -262,6 +250,23 @@ if (WITH_MPI)
262250
endif()
263251
endif()
264252

253+
254+
if(WITH_TAU)
255+
if (CALIPER_HAVE_MPI)
256+
find_package(TAU QUIET)
257+
if (TAU_FOUND)
258+
set(CALIPER_HAVE_TAU TRUE)
259+
set(CALIPER_TAU_CMAKE_MSG "Yes, using ${TAU_LIBRARIES}")
260+
list(APPEND CALIPER_MPI_EXTERNAL_LIBS ${TAU_LIBRARIES})
261+
else()
262+
message(WARNING "TAU bindings requested but TAU API was not found!\n"
263+
"Set TAU_PREFIX to installation path and re-run cmake.")
264+
endif()
265+
else()
266+
message(WARNING "TAU support requires MPI-enabled build!\n")
267+
endif()
268+
endif()
269+
265270
# Find Python
266271

267272
find_package(PythonInterp REQUIRED)

mpi/mpi-rt/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ endmacro()
3030
add_subdirectory(services/mpiwrap)
3131
add_subdirectory(services/mpireport)
3232

33+
if (CALIPER_HAVE_TAU)
34+
add_subdirectory(services/tau)
35+
endif()
36+
3337
add_subdirectory(controllers)
3438

3539
if (CALIPER_HAVE_MPIT)
@@ -45,6 +49,10 @@ add_library(caliper-mpi
4549
set_target_properties(caliper-mpi PROPERTIES SOVERSION ${CALIPER_MAJOR_VERSION})
4650
set_target_properties(caliper-mpi PROPERTIES VERSION ${CALIPER_VERSION})
4751

52+
foreach (_extlib ${CALIPER_MPI_EXTERNAL_LIBS})
53+
target_link_libraries(caliper-mpi PRIVATE ${_extlib})
54+
endforeach()
55+
4856
target_link_libraries(caliper-mpi PUBLIC caliper-mpi-common caliper)
4957
target_link_libraries(caliper-mpi PRIVATE ${MPI_CXX_LIBRARIES})
5058

src/services/tau/CMakeLists.txt mpi/mpi-rt/services/tau/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ set(CALIPER_TAU_SOURCES
55

66
add_library(caliper-tau OBJECT ${CALIPER_TAU_SOURCES})
77

8-
add_service_objlib("caliper-tau")
9-
add_caliper_service("tau CALIPER_HAVE_TAU")
8+
add_mpi_service_objlib("caliper-tau")
9+
File renamed without changes.

src/services/tau/tau.cpp mpi/mpi-rt/services/tau/tau.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#define TAU_DOT_H_LESS_HEADERS
4545
#include "TAU.h"
4646

47+
#include <mpi.h>
4748

4849
using namespace cali;
4950

@@ -62,19 +63,22 @@ class TAUBinding : public cali::AnnotationBinding
6263
char* argv[1];
6364
argv[0] = const_cast<char*>(dummy);
6465
Tau_init(argc,argv);
65-
// want to get the *real* MPI rank. How do I get it? like this.
66-
Attribute mpi_rank_attr = c->get_attribute("mpi.rank");
67-
if (mpi_rank_attr == Attribute::invalid) {
68-
// no MPI
66+
67+
int flag = 0;
68+
PMPI_Initialized(&flag);
69+
70+
if (flag == 0) {
6971
Tau_set_node(0);
7072
} else {
71-
// have MPI, get the rank
72-
Tau_set_node(c->get(chn, mpi_rank_attr).value().to_int());
73+
int rank = 0;
74+
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
75+
76+
Tau_set_node(rank);
7377
}
7478
// register for events of interest?
7579
}
7680

77-
void finalize(Caliper* c) {
81+
void finalize(Caliper*, Channel*) {
7882
// do something?
7983
}
8084

@@ -92,7 +96,7 @@ class TAUBinding : public cali::AnnotationBinding
9296
// handle an end event by stopping a TAU timer
9397
void on_end(Caliper* c, Channel*, const Attribute& attr, const Variant& value) {
9498
if (attr.type() == CALI_TYPE_STRING) {
95-
Tau_stop((const char*)(value.data());
99+
Tau_stop((const char*) value.data());
96100
} else {
97101
Tau_stop((const char*)(value.to_string().data()));
98102
}
@@ -101,7 +105,10 @@ class TAUBinding : public cali::AnnotationBinding
101105

102106
} // namespace
103107

104-
namespace cali {
105-
CaliperService tau_service { "tau", &AnnotationBinding::make_binding<::TAUBinding> };
108+
namespace cali
109+
{
110+
111+
CaliperService tau_service { "tau", &AnnotationBinding::make_binding<::TAUBinding> };
112+
106113
}
107114

mpi/mpi-rt/setup_mpi.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ extern CaliperService mpireport_service;
5454
#ifdef CALIPER_HAVE_MPIT
5555
extern CaliperService mpit_service;
5656
#endif
57+
#ifdef CALIPER_HAVE_TAU
58+
extern CaliperService tau_service;
59+
#endif
5760

5861
CaliperService cali_mpi_services[] = {
5962
mpiwrap_service,
6063
mpireport_service,
6164
#ifdef CALIPER_HAVE_MPIT
6265
mpit_service,
66+
#endif
67+
#ifdef CALIPER_HAVE_TAU
68+
tau_service,
6369
#endif
6470
{ nullptr, nullptr }
6571
};

src/services/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ if (CALIPER_HAVE_DYNINST)
7878
add_subdirectory(symbollookup)
7979
add_subdirectory(instlookup)
8080
endif()
81-
if (CALIPER_HAVE_TAU)
82-
add_subdirectory(tau)
83-
endif()
8481

8582
add_subdirectory(trace)
8683
# if (CALIPER_HAVE_OMPT)

test/ci_app_tests/CMakeLists.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ if (CALIPER_HAVE_SAMPLER AND CALIPER_HAVE_DYNINST)
7474
list(APPEND PYTHON_SCRIPTS test_sampler.py)
7575
endif()
7676

77-
if (CALIPER_HAVE_TAU)
78-
add_executable(ci_test_tau_service ci_test_tau_service.cpp)
79-
target_link_libraries(ci_test_tau_service caliper ${TAU_LIBRARIES})
80-
list(APPEND PYTHON_SCRIPTS test_tau_service.py)
81-
endif()
82-
8377
if (CALIPER_HAVE_MPI)
8478
include_directories(${MPI_CXX_INCLUDE_PATH})
8579
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../mpi/include)
@@ -91,7 +85,11 @@ if (CALIPER_HAVE_MPI)
9185

9286
if (RUN_MPI_TESTS)
9387
list(APPEND PYTHON_SCRIPTS test_mpi.py)
94-
endif()
88+
89+
if (CALIPER_HAVE_TAU)
90+
list(APPEND PYTHON_SCRIPTS test_tau_service.py)
91+
endif()
92+
endif()
9593
endif()
9694

9795
foreach(file ${PYTHON_SCRIPTS})

test/ci_app_tests/test_tau_service.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ class CaliperReportTest(unittest.TestCase):
88
""" Caliper TAU service test case """
99

1010
def test_tau(self):
11-
target_cmd = [ './ci_test_tau_service' ]
12-
query_cmd = [ '../../src/tools/cali-query/cali-query',
13-
'-q', 'SELECT count(),iteration#fooloop WHERE loop=fooloop GROUP BY iteration#fooloop FORMAT expand' ]
11+
target_cmd = [ './ci_test_mpi_before_cali' ]
1412

1513
caliper_config = {
16-
'CALI_SERVICES_ENABLE' : 'event,trace,report,tau',
17-
'CALI_REPORT_CONFIG' : 'format cali',
18-
'CALI_LOG_VERBOSITY' : '0'
14+
'CALI_SERVICES_ENABLE' : 'tau',
15+
'CALI_LOG_VERBOSITY' : '0',
16+
'TAU_PROFILE' : '0',
17+
'TAU_TRACE' : '0'
1918
}
2019

2120
#query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config)

0 commit comments

Comments
 (0)