-
Notifications
You must be signed in to change notification settings - Fork 12
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
[DO NOT MERGE] Parallel execution #259
Open
SudeshnaBora
wants to merge
10
commits into
master
Choose a base branch
from
parallel_execution
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
472ea51
Add code for prallel execution
SudeshnaBora 14164f6
Add cuda_standalone generated files
SudeshnaBora 97a8116
Parallelize code execution
SudeshnaBora 20fa0ba
Add code change for parallel execution
SudeshnaBora 54cac5f
Change variable in template
SudeshnaBora 5e51beb
Add missing header file
denisalevi 1a1c7e9
Add CUDA stream parameter to `codeobj_func` typedef
denisalevi 45fbc57
Add cuda stream in network
SudeshnaBora 2555e2e
Add synaptic changes
SudeshnaBora 417baa8
Link cudart during compilation
denisalevi 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
Add cuda stream in network
- Loading branch information
commit 45fbc5702938ce927928174c30a67e38f5318655
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,18 @@ | |
|
||
double Network::_last_run_time = 0.0; | ||
double Network::_last_run_completed_fraction = 0.0; | ||
{% if parallelize %} | ||
cudaStream_t custom_stream[{{num_stream}}]; | ||
{% endif %} | ||
|
||
Network::Network() | ||
{ | ||
t = 0.0; | ||
{% if parallelize %} | ||
for(int i=0;i<{{num_stream}};i++){ | ||
CUDA_SAFE_CALL(cudaStreamCreate(&(custom_stream[i]))); | ||
} | ||
{% endif %} | ||
} | ||
|
||
void Network::clear() | ||
|
@@ -90,8 +98,8 @@ void Network::run(const double duration, void (*report_func)(const double, const | |
int func_group_int = std::get<2>(objects[i]); | ||
if (func) // code objects can be NULL in cases where we store just the clock | ||
{ | ||
//func_groups[func_group_int].push_back(func); | ||
func_groups.push_back(std::make_pair(func_group_int,func)); | ||
func_groups[func_group_int].push_back(func); | ||
//func_groups.push_back(std::make_pair(func_group_int,func)); | ||
//func(); | ||
// [[func1,func2,func3],[func4...]] | ||
} | ||
|
@@ -101,10 +109,13 @@ void Network::run(const double duration, void (*report_func)(const double, const | |
// get maximum in objects.cu array | ||
|
||
// go through each list of func group - 2 loops | ||
for(int i=0; i<func_groups.size(); i++) { | ||
codeobj_func func = func_groups[i].second; | ||
//func(cuda_streams[i]); | ||
func(); | ||
for(int i=0; i<func_groups.size(); i++){ | ||
for(int j=0; j<func_groups.size(); j++){ | ||
codeobj_func func = func_groups[i][j]; | ||
func(custom_stream[j]); | ||
} | ||
// reset the func group for that sub stream | ||
func_groups.resize(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After each function group, you need to synchronize host and device. Check the documentation if |
||
} | ||
|
||
for(std::set<Clock*>::iterator i=curclocks.begin(); i!=curclocks.end(); i++) | ||
|
@@ -209,11 +220,15 @@ public: | |
// TODO vectory of tuples having clock , codeobj_func and stread integer | ||
std::vector< std::tuple< Clock*, codeobj_func, int > > objects; | ||
//std::vector< std::pair< Clock*, codeobj_func > > objects; | ||
std::vector<std::pair< int, codeobj_func >> func_groups; | ||
std::vector<std::vector<codeobj_func >> func_groups = std::vector<std::vector<codeobj_func >>({{num_stream}}); | ||
//std::vector<std::pair< int, codeobj_func >> func_groups; | ||
double t; | ||
static double _last_run_time; | ||
static double _last_run_completed_fraction; | ||
int num_streams; | ||
{% if parallelize %} | ||
cudaStream_t custom_stream[{{num_stream}}]; | ||
{% endif %} | ||
|
||
Network(); | ||
void clear(); | ||
|
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
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.
The second loop is wrong: