Skip to content

Commit

Permalink
[ GPU ] move initBlaseClKernels() to registerer
Browse files Browse the repository at this point in the history
- With the current version code, a user should be care about the timing
of to call `initBlasClKernels()`. However, it is not desirable, causing
some unexpected errors.
- Instead of that, this commit moves the `initBlasClKernels()` into
registerer, which is called once in Global().

Self evaluation:

Build test: [X]Passed [ ]Failed [ ]Skipped
Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Eunju Yang <ej.yang@samsung.com>
  • Loading branch information
EunjuYang committed Oct 25, 2024
1 parent 89e8b7c commit 1123b82
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions nntrainer/cl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static void add_default_object(ClContext &cc) {

static void registerer(ClContext &cc) noexcept {
try {
cc.initBlasClKernels();
add_default_object(cc);
} catch (std::exception &e) {
ml_loge("cl_context: registering layers failed!!, reason: %s", e.what());
Expand Down
2 changes: 0 additions & 2 deletions nntrainer/layers/layer_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ createLayerNode(const ml::train::LayerType &type,
#ifdef ENABLE_OPENCL
if (compute_engine == ml::train::LayerComputeEngine::GPU) {
auto &cc = nntrainer::ClContext::Global();
cc.initBlasClKernels();
return createLayerNode(cc.createObject<nntrainer::Layer>(type), properties,
compute_engine);
}
Expand All @@ -158,7 +157,6 @@ createLayerNode(const std::string &type,
#ifdef ENABLE_OPENCL
if (compute_engine == ml::train::LayerComputeEngine::GPU) {
auto &cc = nntrainer::ClContext::Global();
cc.initBlasClKernels();
return createLayerNode(cc.createObject<nntrainer::Layer>(type), properties,
compute_engine);
}
Expand Down
5 changes: 1 addition & 4 deletions test/unittest/unittest_blas_kernels_cl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@

using namespace nntrainer;

static void setUpGpuContext() {
auto &ac = nntrainer::ClContext::Global();
ac.initBlasClKernels();
}
static void setUpGpuContext() { auto &ac = nntrainer::ClContext::Global(); }

TEST(blas_kernels, dotCL_sgemv) {
setUpGpuContext();
Expand Down

0 comments on commit 1123b82

Please sign in to comment.