-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Camille Coti
committed
Jan 13, 2023
1 parent
a230050
commit 6c82784
Showing
5 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# - Try to find PhiProf | ||
# Once done this will define | ||
# PHIPROF_FOUND - System has PhiProf | ||
# STARPU_INCLUDE_DIRS - The include directories | ||
|
||
|
||
find_package(PkgConfig) | ||
|
||
if(NOT DEFINED $PHIPROF_ROOT) | ||
if(DEFINED ENV{PHIPROF_ROOT}) | ||
# message(" env PHIPROF_ROOT is defined as $ENV{PHIPROF_ROOT}") | ||
set(PHIPROF_ROOT $ENV{PHIPROF_ROOT}) | ||
endif() | ||
endif() | ||
|
||
if(NOT DEFINED $PHIPROF_ROOT) | ||
if(DEFINED PHIPROF_DIR) | ||
# message(" env PHIPROF_ROOT is defined as $ENV{PHIPROF_ROOT}") | ||
set(PHIPROF_ROOT $PHIPROF_DIR) | ||
endif() | ||
endif() | ||
|
||
message(INFO " will check ${PHIPROF_ROOT} for PHIPROF") | ||
set(CMAKE_PREFIX_PATH} "${CMAKE_PREFIX_PATH} ${PHIPROF_ROOT}") | ||
set(ENV{PKG_CONFIG_PATH} "${PHIPROF_ROOT}/libs/pkgconfig") | ||
pkg_check_modules(PHIPROF QUIET libstarpu) | ||
|
||
if(NOT PHIPROF_FOUND) | ||
find_path(PHIPROF_INCLUDE_DIR NAMES phiprof.hpp | ||
HINTS ${PHIPROF_ROOT}/include) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set PHIPROF_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
find_package_handle_standard_args(PHIPROF DEFAULT_MSG | ||
PHIPROF_INCLUDE_DIR) | ||
|
||
mark_as_advanced(PHIPROF_INCLUDE_DIR) | ||
message( "Using ${PHIPROF_INCLUDE_DIR} as PhiProf include dir" ) | ||
|
||
if(PHIPROF_FOUND) | ||
set(PHIPROF_INCLUDE_DIRS ${PHIPROF_INCLUDE_DIR}) | ||
set(PHIPROF_DIR ${PHIPROF_ROOT}) | ||
add_definitions(-DAPEX_HAVE_PHIPROF) | ||
endif() | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include <map> | ||
#include <mpi.h> | ||
#include <mutex> | ||
#include <stack> | ||
#include "apex.hpp" | ||
#include <phiprof.hpp> | ||
|
||
#warning compiling phiprof | ||
|
||
/* Correspondance between labels and ids */ | ||
|
||
std::mutex mut; | ||
|
||
std::map<std::string, int> timers_labels; | ||
std::map<int, std::string> timers_ids; | ||
|
||
int insertOrGet( const std::string &label ){ | ||
int id; | ||
mut.lock(); | ||
auto it = timers_labels.find( label ); | ||
if( it == timers_labels.end() ){ | ||
id = timers_labels.size(); | ||
timers_labels[ label ] = id; | ||
timers_ids[ id ] = label; | ||
} else { | ||
id = it->second; | ||
} | ||
mut.unlock(); | ||
return id; | ||
} | ||
|
||
|
||
/* Simple initialization. Returns true if started succesfully */ | ||
|
||
bool phiprof::initialize(){ | ||
return true; | ||
} | ||
|
||
/* Initialize a timer, with a particular label | ||
* | ||
* Initialize a timer. This enables one to define groups, and to use | ||
* the return id value for more efficient starts/stops in tight | ||
* loops. If this function is called for an existing timer it will | ||
* simply just return the id. | ||
*/ | ||
|
||
int phiprof::initializeTimer(const std::string &label, const std::vector<std::string> &groups){ | ||
return insertOrGet( label ); | ||
} | ||
|
||
int phiprof::initializeTimer(const std::string &label){ | ||
return insertOrGet( label ); | ||
} | ||
|
||
int phiprof::initializeTimer(const std::string &label,const std::string &group1) { | ||
return insertOrGet( label ); | ||
} | ||
|
||
int phiprof::initializeTimer(const std::string &label,const std::string &group1,const std::string &group2){ | ||
return insertOrGet( label ); | ||
} | ||
|
||
int phiprof::initializeTimer(const std::string &label,const std::string &group1,const std::string &group2,const std::string &group3){ | ||
return insertOrGet( label ); | ||
} | ||
|
||
/* Get id number of an existing timer that is a child of the currently | ||
* active one */ | ||
|
||
int phiprof::getChildId(const std::string &label){ | ||
/* TODO */ | ||
return -1; | ||
} | ||
|
||
/* Start-stop timers */ | ||
|
||
static thread_local std::stack<std::shared_ptr<apex::task_wrapper> > my_stack; | ||
|
||
|
||
bool phiprof::start(const std::string &label){ | ||
auto t = apex::new_task( label ); | ||
apex::start( t ); | ||
my_stack.push(t); | ||
return true; | ||
} | ||
|
||
bool phiprof::start(int id){ | ||
auto label = timers_ids[ id ]; | ||
auto t = apex::new_task( label ); | ||
apex::start( t ); | ||
my_stack.push(t); | ||
return true; | ||
} | ||
|
||
bool phiprof::stop (const std::string &label, double workUnits, const std::string &workUnitLabel){ | ||
auto t = my_stack.top(); | ||
apex::stop(t); | ||
my_stack.pop(); | ||
return true; | ||
} | ||
|
||
bool phiprof::stop (int id, double workUnits, const std::string &workUnitLabel){ | ||
auto t = my_stack.top(); | ||
apex::stop(t); | ||
my_stack.pop(); | ||
return true; | ||
} | ||
|
||
bool phiprof::stop (int id){ | ||
auto t = my_stack.top(); | ||
apex::stop(t); | ||
my_stack.pop(); | ||
return true; | ||
} | ||
|
||
bool phiprof::print(MPI_Comm comm, std::string fileNamePrefix){ | ||
return true; | ||
} | ||
|