Last active
October 5, 2021 21:11
-
-
Save DavidPoliakoff/2e3c0ff13b4277c18371ab600a53b58e to your computer and use it in GitHub Desktop.
Writing the Tool Layer
This file contains hidden or 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
function_pointer_that_takes_a_string begin_parallel_for_ptr; | |
function_pointer_that_takes_a_string end_parallel_for_ptr; | |
void initialize(std::string toolLibrary) { | |
void* handle = dlopen(toolLibrary); | |
begin_parallel_for_ptr = dlsym(handle, "kokkosp_begin_parallel_for"); | |
end_parallel_for_ptr = dlsym(handle, "kokkosp_end_parallel_for"); | |
} | |
void parallel_for(std::string label, boring_parallelism_stuff stuff) { | |
if(begin_parallel_for_ptr){ | |
fence_kokkos(); // this is a _small_ lie | |
(*begin_parallel_for_ptr)(label); | |
} | |
// run boring parallel code here | |
if(end_parallel_for_ptr){ | |
fence_kokkos(); // this is a _small_ lie | |
(*end_parallel_for_ptr)(label); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment