Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(profiler): added option to cmake build to configure NUM_WORKERS #448

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/Manual_Quickstart/Manual_Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ If you have installed LLVM <b>using the package manager</b>, specifying this var
Note: In case you want to use a specific Version of LLVM, it is possible to specify the `-DUSE_LLVM_VERSION=<version>` flag.

Note: In case your application uses PThreads, please specify `-DDP_PTHREAD_COMPATIBILITY_MODE=1`. Note, however, that this can influence the runtime of the profiling.

Note: In case you require a more verbose output of the runtime library, specify the `-DDP_RTLIB_VERBOSE=1` flag.

Note: In case you want to specify the number of Workers available for the profiling step, specify the `-DDP_NUM_WORKERS=<int>` flag.

Once the configuration process is successfully finished, compile the DiscoPoP libraries using `make`. All created shared objects will be stored in the build directory and can be found inside a folder named `libi/`.

make
Expand Down
7 changes: 7 additions & 0 deletions rtlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ if(DEFINED DP_RTLIB_VERBOSE)
target_compile_definitions(DiscoPoP_RT PUBLIC DP_RTLIB_VERBOSE=${DP_RTLIB_VERBOSE})
endif()
endif()

if(DEFINED DP_NUM_WORKERS)
if(NOT ${DP_NUM_WORKERS} EQUAL 0)
target_compile_definitions(DiscoPoP_RT PUBLIC DP_NUM_WORKERS=${DP_NUM_WORKERS})
endif()
endif()

# end of compiler flags

install(TARGETS DiscoPoP_RT ARCHIVE DESTINATION lib)
Expand Down
7 changes: 7 additions & 0 deletions rtlib/iFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ namespace __dp {
pthread_mutex_t allDepsLock;
pthread_t *workers = nullptr; // worker threads

#define XSTR(x) STR(x)
#define STR(x) #x
#ifdef DP_NUM_WORKERS
#pragma message "Profiler: set NUM_WORKERS to " XSTR(DP_NUM_WORKERS)
int32_t NUM_WORKERS = DP_NUM_WORKERS;
#else
int32_t NUM_WORKERS = 3; // default number of worker threads (multiple workers can potentially lead to non-deterministic results)
#endif
int32_t CHUNK_SIZE = 500; // default number of addresses in each chunk
queue<AccessInfo *> *chunks = nullptr; // one queue of access info chunks for each worker thread
bool *addrChunkPresent = nullptr; // addrChunkPresent[thread_id] denotes whether or not a new chunk is available for the corresponding thread
Expand Down