-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use RAJA plugin capability #224
Merged
Merged
Changes from 33 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
3270b20
plugins
623221d
Delete BenchmarkPlugin.cpp
neelakausik a779f5e
undoing accidental changes
0128aee
Merge branch 'feature/kausik1/plugins' of https://github.com/LLNL/CAR…
ac5f37e
fix RAJAPlugin.cpp
e932a33
resolved some issues
2cbb56e
small tweak
5a4ee77
fixed formatting
bb73878
trying to revert 2 files and deleted RAJAPlugin class
4838863
replaced calls to RAJAPlugin
4b21f12
fixing build errors hopefully
7d0f25e
fix vector error
0e556f3
Merge branch 'develop' into feature/kausik1/plugins
neelakausik 2941ed7
Merge branch 'develop' into feature/kausik1/plugins
adayton1 c758f8f
new class for plugin data
15ce40b
Merge branch 'feature/kausik1/plugins' of https://github.com/LLNL/CAR…
37eaa87
manually set chai execution space for 2d
ee08aca
fixed plugindata class
1b2a7c0
remove unnecessary includes
ce7f9ec
fixed formatting and small issues
07ad1d5
registration function
b968cf9
fixed reg function
1c4e47f
Merge branch 'develop' into feature/kausik1/plugins
neelakausik d2241d3
resolved comments
c046990
Merge branch 'feature/kausik1/plugins' of https://github.com/LLNL/CAR…
e98394e
Delete BenchmarkForall.cpp
neelakausik 7422eb6
removed streams stuff
f5899fc
Merge branch 'feature/kausik1/plugins' of https://github.com/LLNL/CAR…
50858aa
restored orignal BenchmarkForall.cpp
5119e23
Care->CARE
3d66171
resolved more comments
95ad98a
resolved comments and errors
00efa02
fixes profileplugin registration
80a8b17
added comments and formatting
f4388e0
fixed HIP warning
36cf8a0
tweaked plugindata description
52475a1
actionmap alias
7ef02b2
forgot one actionmap
6d59f0a
move actionmap inside care namespace
65ab328
fix indentation
6fabbdb
Merge branch 'develop' into feature/kausik1/plugins
adayton1 013ff95
try to fix printf errors
8f42b88
Merge branch 'feature/kausik1/plugins' of https://github.com/LLNL/CAR…
6c887d0
fixed warnings in debugplugin and forall
c123396
maybe silence profileplugin warnings
52504cd
forall unused parameter warning
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,139 @@ | ||
#include "care/DebugPlugin.h" | ||
#include "chai/ExecutionSpaces.hpp" | ||
#include "care/CHAICallback.h" | ||
#include "care/PluginData.h" | ||
|
||
// Std library headers | ||
#if defined(CARE_DEBUG) && !defined(_WIN32) | ||
#include <execinfo.h> | ||
#endif // defined(CARE_DEBUG) && !defined(_WIN32) | ||
|
||
#include <unordered_set> | ||
|
||
namespace care{ | ||
void DebugPlugin::registerPlugin() { | ||
static RAJA::util::PluginRegistry::add<care::DebugPlugin> L ("Debug plugin", "CARE plugin for debugging"); | ||
} | ||
|
||
void DebugPlugin::preLaunch(const RAJA::util::PluginContext& p) { | ||
#if !defined(CHAI_DISABLE_RM) | ||
// Prepare to record CHAI data | ||
if (CHAICallback::isActive()) { | ||
PluginData::clearActivePointers(); | ||
|
||
#if defined(CARE_GPUCC) && defined(CARE_DEBUG) | ||
GPUWatchpoint::setOrCheckWatchpoint<int>(); | ||
#endif // defined(CARE_GPUCC) && defined(CARE_DEBUG) | ||
} | ||
#endif // !defined(CHAI_DISABLE_RM) | ||
} | ||
|
||
|
||
void DebugPlugin::postLaunch(const RAJA::util::PluginContext& p) { | ||
#if !defined(CHAI_DISABLE_RM) | ||
chai::ExecutionSpace space; | ||
|
||
switch (p.platform) { | ||
case RAJA::Platform::host: | ||
space = chai::CPU; break; | ||
adayton1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#if defined(CHAI_ENABLE_CUDA) | ||
case RAJA::Platform::cuda: | ||
space = chai::GPU; break; | ||
#endif | ||
#if defined(CHAI_ENABLE_HIP) | ||
case RAJA::Platform::hip: | ||
space = chai::GPU; break; | ||
#endif | ||
default: | ||
space = chai::NONE; | ||
} | ||
|
||
if (CHAICallback::isActive()) { | ||
writeLoopData(space, PluginData::getFileName(), PluginData::getLineNumber()); | ||
|
||
#if defined(CARE_GPUCC) && defined(CARE_DEBUG) | ||
GPUWatchpoint::setOrCheckWatchpoint<int>(); | ||
#endif // defined(CARE_GPUCC) && defined(CARE_DEBUG) | ||
} | ||
|
||
if (PluginData::isParallelContext()) { | ||
for (auto const & it : PluginData::get_post_parallel_forall_actions()) { | ||
it.second(space, PluginData::getFileName(), PluginData::getLineNumber()); | ||
} | ||
PluginData::clear_post_parallel_forall_actions(); | ||
PluginData::s_threadID = -1; | ||
} | ||
#endif // !defined(CHAI_DISABLE_RM) | ||
} | ||
|
||
void DebugPlugin::writeLoopData(chai::ExecutionSpace space, const char * fileName, int lineNumber) { | ||
if (CHAICallback::loggingIsEnabled()) { | ||
const int s_log_data = CHAICallback::getLogData(); | ||
|
||
if (s_log_data == (int) space || | ||
s_log_data == (int) chai::ExecutionSpace::NUM_EXECUTION_SPACES) { | ||
// Get the output file | ||
FILE* callback_output_file = CHAICallback::getLogFile(); | ||
|
||
// Write the loop header | ||
int numArrays = 0; | ||
std::unordered_set<const chai::PointerRecord*> usedRecords; | ||
|
||
for (const chai::PointerRecord* record : PluginData::getActivePointers()) { | ||
if (usedRecords.count(record) > 0) { | ||
continue; | ||
} | ||
else { | ||
usedRecords.emplace(record); | ||
++numArrays; | ||
} | ||
} | ||
|
||
fprintf(callback_output_file, "[CARE] AFTER LOOP EXECUTION %s:%i (%i arrays)\n", fileName, lineNumber, numArrays); | ||
|
||
#if defined(CARE_DEBUG) && !defined(_WIN32) | ||
// Write the stack trace | ||
const int stackDepth = 16; | ||
void *stackArray[stackDepth]; | ||
size_t stackSize = backtrace(stackArray, stackDepth); | ||
char **stackStrings = backtrace_symbols(stackArray, stackSize); | ||
|
||
// Skip the first two contexts | ||
for (size_t i = 2 ; i < stackSize ; ++i) { | ||
fprintf(callback_output_file, "[CARE] [STACK] %lu: %s\n", i, stackStrings[i]); | ||
} | ||
|
||
if (CHAICallback::isDiffFriendly()) { | ||
// For diff-friendly output, keep the number of lines constant | ||
for (size_t i = stackSize ; i < stackDepth ; ++i) { | ||
fprintf(callback_output_file, "[CARE] [STACK] %lu: <empty>\n", i); | ||
} | ||
} | ||
|
||
free(stackStrings); | ||
#endif // defined(CARE_DEBUG) && !defined(_WIN32) | ||
|
||
// Flush to the output file | ||
fflush(callback_output_file); | ||
|
||
#ifdef CARE_DEBUG | ||
// Write the arrays captured in the loop | ||
usedRecords.clear(); | ||
|
||
for (const chai::PointerRecord* record : PluginData::getActivePointers()) { | ||
if (record && usedRecords.find(record) == usedRecords.end()) { | ||
usedRecords.emplace(record); | ||
CHAICallback::writeArray(record, space); | ||
fflush(callback_output_file); | ||
} | ||
} | ||
#else // CARE_DEBUG | ||
// Write message that -logchaidata is not supported | ||
fprintf(callback_output_file, "[CARE] [CHAI] -logchaidata is not supported in this build\n"); | ||
fflush(callback_output_file); | ||
#endif // CARE_DEBUG | ||
} | ||
} | ||
} | ||
} | ||
|
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,33 @@ | ||
#ifndef _CARE_DebugPlugin_H_ | ||
#define _CARE_DebugPlugin_H_ | ||
|
||
#include "RAJA/util/PluginStrategy.hpp" | ||
#include "chai/ExecutionSpaces.hpp" | ||
|
||
namespace care{ | ||
|
||
class DebugPlugin : public RAJA::util::PluginStrategy | ||
{ | ||
public: | ||
DebugPlugin() = default; | ||
|
||
static void registerPlugin(); | ||
|
||
void preLaunch(const RAJA::util::PluginContext& p) override; | ||
|
||
void postLaunch(const RAJA::util::PluginContext& p) override; | ||
|
||
///////////////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// @brief Writes out debugging information after a loop is executed. | ||
/// | ||
/// @arg[in] space The execution space | ||
/// @arg[in] fileName The file where the loop macro was called | ||
/// @arg[in] lineNumber The line number where the loop macro was called | ||
/// | ||
///////////////////////////////////////////////////////////////////////////////// | ||
static void writeLoopData(chai::ExecutionSpace space, const char * fileName, int lineNumber); | ||
}; | ||
} | ||
|
||
#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,59 @@ | ||
#include "PluginData.h" | ||
|
||
namespace care{ | ||
const char * PluginData::s_file_name = "N/A"; | ||
int PluginData::s_line_number = -1; | ||
bool PluginData::s_parallel_context = false; | ||
std::unordered_map<void *, std::function<void(chai::ExecutionSpace, const char *, int)>> PluginData::s_post_parallel_forall_actions | ||
= std::unordered_map<void *, std::function<void(chai::ExecutionSpace, const char *, int)>>{}; | ||
std::vector<const chai::PointerRecord*> PluginData::s_active_pointers_in_loop = std::vector<const chai::PointerRecord*>{}; | ||
int PluginData::s_threadID = -1; | ||
|
||
void PluginData::setFileName(const char * name) {PluginData::s_file_name = name;} | ||
|
||
void PluginData::setLineNumber(int num) {PluginData::s_line_number = num;} | ||
|
||
const char * PluginData::getFileName() {return s_file_name;} | ||
|
||
int PluginData::getLineNumber() {return s_line_number;} | ||
|
||
void PluginData::setParallelContext(bool isParallel) { | ||
s_parallel_context = isParallel; | ||
} | ||
|
||
bool PluginData::isParallelContext(){ | ||
return s_parallel_context; | ||
} | ||
|
||
std::unordered_map<void *, std::function<void(chai::ExecutionSpace, const char *, int)>> PluginData::get_post_parallel_forall_actions() { | ||
return s_post_parallel_forall_actions; | ||
} | ||
|
||
void PluginData::register_post_parallel_forall_action(void * key, std::function<void(chai::ExecutionSpace, const char *, int)> action) { | ||
s_post_parallel_forall_actions[key] = action; | ||
} | ||
|
||
bool PluginData::post_parallel_forall_action_registered(void * key) { | ||
bool registered = s_post_parallel_forall_actions.count(key) > 0; | ||
return registered; | ||
} | ||
|
||
void PluginData::clear_post_parallel_forall_actions(){s_post_parallel_forall_actions.clear();} | ||
|
||
std::vector<const chai::PointerRecord*> PluginData::getActivePointers() {return s_active_pointers_in_loop;} | ||
|
||
void PluginData::addActivePointer(const chai::PointerRecord* record) { | ||
s_active_pointers_in_loop.emplace_back(record); | ||
} | ||
|
||
void PluginData::removeActivePointer(const chai::PointerRecord* record) { | ||
for (size_t i = 0; i < s_active_pointers_in_loop.size(); ++i) { | ||
if (s_active_pointers_in_loop[i] == record) { | ||
s_active_pointers_in_loop[i] = nullptr; | ||
} | ||
} | ||
} | ||
|
||
void PluginData::clearActivePointers() {s_active_pointers_in_loop.clear();} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robinson96, can we remove the GPUWatchpoint stuff? Since we are not passing any address to it, I don't see how it can do anything useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see - you'd have to manually set a watchpoint before the loop. But I looked it up and cuda-gdb at least has the ability to set a watchpoint on both host and GPU memory. So I don't think we need this watchpoint code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait. cuda-gdb only supports watchpoints on host memory. Sad day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question still remains, though, is this used enough to keep it around? I've never used it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the ROCm platform supports watchpoints on device memory: https://docs.amd.com/projects/ROCdbgapi/en/docs-5.0.0/doxygen/docBin/html/group__watchpoint__group.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can leave the support in for now and it would be easy to remove later if we decide to get rid of it.