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

Create executor in exec_map only if requested. #602

Merged
merged 4 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 16 additions & 8 deletions examples/custom-matrix-format/custom-matrix-format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,25 @@ int main(int argc, char *argv[])
const auto executor_string = argc >= 3 ? argv[2] : "reference";

// Figure out where to run the code
const auto omp = gko::OmpExecutor::create();
std::map<std::string, std::shared_ptr<gko::Executor>> exec_map{
{"omp", omp},
{"cuda", gko::CudaExecutor::create(0, omp, true)},
{"hip", gko::HipExecutor::create(0, omp, true)},
{"reference", gko::ReferenceExecutor::create()}};
std::map<std::string, std::function<std::shared_ptr<gko::Executor>()>>
exec_map{
{"omp", [] { return gko::OmpExecutor::create(); }},
{"cuda",
[] {
return gko::CudaExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"hip",
[] {
return gko::HipExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"reference", [] { return gko::ReferenceExecutor::create(); }}};

// executor where Ginkgo will perform the computation
const auto exec = exec_map.at(executor_string); // throws if not valid
const auto exec = exec_map.at(executor_string)(); // throws if not valid
// executor used by the application
const auto app_exec = exec_map["omp"];
const auto app_exec = exec_map["omp"]();

// problem:
auto correct_u = [](ValueType x) { return x * x * x; };
Expand Down
25 changes: 17 additions & 8 deletions examples/nine-pt-stencil-solver/nine-pt-stencil-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,25 @@ void solve_system(const std::string &executor_string,
const gko::size_type dp_2 = dp * dp;

// Figure out where to run the code
const auto omp = gko::OmpExecutor::create();
std::map<std::string, std::shared_ptr<gko::Executor>> exec_map{
{"omp", omp},
{"cuda", gko::CudaExecutor::create(0, omp, true)},
{"hip", gko::HipExecutor::create(0, omp, true)},
{"reference", gko::ReferenceExecutor::create()}};
std::map<std::string, std::function<std::shared_ptr<gko::Executor>()>>
exec_map{
{"omp", [] { return gko::OmpExecutor::create(); }},
{"cuda",
[] {
return gko::CudaExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"hip",
[] {
return gko::HipExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"reference", [] { return gko::ReferenceExecutor::create(); }}};

// executor where Ginkgo will perform the computation
const auto exec = exec_map.at(executor_string); // throws if not valid
const auto exec = exec_map.at(executor_string)(); // throws if not valid
// executor where the application initialized the data
const auto app_exec = exec_map["omp"];
const auto app_exec = exec_map["omp"]();

// Tell Ginkgo to use the data in our application

Expand Down
24 changes: 16 additions & 8 deletions examples/poisson-solver/poisson-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,25 @@ int main(int argc, char *argv[])
const auto executor_string = argc >= 3 ? argv[2] : "reference";

// Figure out where to run the code
const auto omp = gko::OmpExecutor::create();
std::map<std::string, std::shared_ptr<gko::Executor>> exec_map{
{"omp", omp},
{"cuda", gko::CudaExecutor::create(0, omp, true)},
{"hip", gko::HipExecutor::create(0, omp, true)},
{"reference", gko::ReferenceExecutor::create()}};
std::map<std::string, std::function<std::shared_ptr<gko::Executor>()>>
exec_map{
{"omp", [] { return gko::OmpExecutor::create(); }},
{"cuda",
[] {
return gko::CudaExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"hip",
[] {
return gko::HipExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"reference", [] { return gko::ReferenceExecutor::create(); }}};

// executor where Ginkgo will perform the computation
const auto exec = exec_map.at(executor_string); // throws if not valid
const auto exec = exec_map.at(executor_string)(); // throws if not valid
// executor used by the application
const auto app_exec = exec_map["omp"];
const auto app_exec = exec_map["omp"]();

// problem:
auto correct_u = [](ValueType x) { return x * x * x; };
Expand Down
25 changes: 17 additions & 8 deletions examples/three-pt-stencil-solver/three-pt-stencil-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,25 @@ void solve_system(const std::string &executor_string,
const auto &dp = discretization_points;

// Figure out where to run the code
const auto omp = gko::OmpExecutor::create();
std::map<std::string, std::shared_ptr<gko::Executor>> exec_map{
{"omp", omp},
{"cuda", gko::CudaExecutor::create(0, omp, true)},
{"hip", gko::HipExecutor::create(0, omp, true)},
{"reference", gko::ReferenceExecutor::create()}};
std::map<std::string, std::function<std::shared_ptr<gko::Executor>()>>
exec_map{
{"omp", [] { return gko::OmpExecutor::create(); }},
{"cuda",
[] {
return gko::CudaExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"hip",
[] {
return gko::HipExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"reference", [] { return gko::ReferenceExecutor::create(); }}};

// executor where Ginkgo will perform the computation
const auto exec = exec_map.at(executor_string); // throws if not valid
const auto exec = exec_map.at(executor_string)(); // throws if not valid
// executor where the application initialized the data
const auto app_exec = exec_map["omp"];
const auto app_exec = exec_map["omp"]();

// Tell Ginkgo to use the data in our application

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,25 @@ void solve_system(const std::string &executor_string,
const size_t dp_3 = dp * dp * dp;

// Figure out where to run the code
const auto omp = gko::OmpExecutor::create();
std::map<std::string, std::shared_ptr<gko::Executor>> exec_map{
{"omp", omp},
{"cuda", gko::CudaExecutor::create(0, omp, true)},
{"hip", gko::HipExecutor::create(0, omp, true)},
{"reference", gko::ReferenceExecutor::create()}};
std::map<std::string, std::function<std::shared_ptr<gko::Executor>()>>
exec_map{
{"omp", [] { return gko::OmpExecutor::create(); }},
{"cuda",
[] {
return gko::CudaExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"hip",
[] {
return gko::HipExecutor::create(0, gko::OmpExecutor::create(),
true);
}},
{"reference", [] { return gko::ReferenceExecutor::create(); }}};

// executor where Ginkgo will perform the computation
const auto exec = exec_map.at(executor_string); // throws if not valid
const auto exec = exec_map.at(executor_string)(); // throws if not valid
// executor where the application initialized the data
const auto app_exec = exec_map["omp"];
const auto app_exec = exec_map["omp"]();

// Tell Ginkgo to use the data in our application

Expand Down