Skip to content

Commit

Permalink
[kernels] remove GKO_DEVICE_NAMESPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Aug 20, 2024
1 parent 590713c commit b35d079
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 39 deletions.
37 changes: 18 additions & 19 deletions common/cuda_hip/base/batch_multi_vector_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ void scale(std::shared_ptr<const DefaultExecutor> exec,
const auto alpha_ub = get_batch_struct(alpha);
const auto x_ub = get_batch_struct(x);
if (alpha->get_common_size()[1] == 1) {
GKO_DEVICE_NAMESPACE::batch_single_kernels::scale_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
batch_single_kernels::scale_kernel<<<num_blocks, default_block_size, 0,
exec->get_stream()>>>(
alpha_ub, x_ub,
[] __device__(int row, int col, int stride) { return 0; });
} else if (alpha->get_common_size() == x->get_common_size()) {
GKO_DEVICE_NAMESPACE::batch_single_kernels::scale_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
batch_single_kernels::scale_kernel<<<num_blocks, default_block_size, 0,
exec->get_stream()>>>(
alpha_ub, x_ub, [] __device__(int row, int col, int stride) {
return row * stride + col;
});
} else {
GKO_DEVICE_NAMESPACE::batch_single_kernels::scale_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
batch_single_kernels::scale_kernel<<<num_blocks, default_block_size, 0,
exec->get_stream()>>>(
alpha_ub, x_ub,
[] __device__(int row, int col, int stride) { return col; });
}
Expand All @@ -71,11 +71,11 @@ void add_scaled(std::shared_ptr<const DefaultExecutor> exec,
const auto x_ub = get_batch_struct(x);
const auto y_ub = get_batch_struct(y);
if (alpha->get_common_size()[1] == 1) {
GKO_DEVICE_NAMESPACE::batch_single_kernels::add_scaled_kernel<<<
batch_single_kernels::add_scaled_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
alpha_ub, x_ub, y_ub, [] __device__(int col) { return 0; });
} else {
GKO_DEVICE_NAMESPACE::batch_single_kernels::add_scaled_kernel<<<
batch_single_kernels::add_scaled_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
alpha_ub, x_ub, y_ub, [] __device__(int col) { return col; });
}
Expand All @@ -96,10 +96,9 @@ void compute_dot(std::shared_ptr<const DefaultExecutor> exec,
const auto x_ub = get_batch_struct(x);
const auto y_ub = get_batch_struct(y);
const auto res_ub = get_batch_struct(result);
GKO_DEVICE_NAMESPACE::batch_single_kernels::
compute_gen_dot_product_kernel<<<num_blocks, default_block_size, 0,
exec->get_stream()>>>(
x_ub, y_ub, res_ub, [] __device__(auto val) { return val; });
batch_single_kernels::compute_gen_dot_product_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
x_ub, y_ub, res_ub, [] __device__(auto val) { return val; });
}

GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(
Expand All @@ -117,10 +116,9 @@ void compute_conj_dot(std::shared_ptr<const DefaultExecutor> exec,
const auto x_ub = get_batch_struct(x);
const auto y_ub = get_batch_struct(y);
const auto res_ub = get_batch_struct(result);
GKO_DEVICE_NAMESPACE::batch_single_kernels::
compute_gen_dot_product_kernel<<<num_blocks, default_block_size, 0,
exec->get_stream()>>>(
x_ub, y_ub, res_ub, [] __device__(auto val) { return conj(val); });
batch_single_kernels::compute_gen_dot_product_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(
x_ub, y_ub, res_ub, [] __device__(auto val) { return conj(val); });
}

GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(
Expand All @@ -136,8 +134,9 @@ void compute_norm2(std::shared_ptr<const DefaultExecutor> exec,
const auto num_rhs = x->get_common_size()[1];
const auto x_ub = get_batch_struct(x);
const auto res_ub = get_batch_struct(result);
GKO_DEVICE_NAMESPACE::batch_single_kernels::compute_norm2_kernel<<<
num_blocks, default_block_size, 0, exec->get_stream()>>>(x_ub, res_ub);
batch_single_kernels::compute_norm2_kernel<<<num_blocks, default_block_size,
0, exec->get_stream()>>>(
x_ub, res_ub);
}

GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(
Expand All @@ -152,7 +151,7 @@ void copy(std::shared_ptr<const DefaultExecutor> exec,
const auto num_blocks = x->get_num_batch_items();
const auto result_ub = get_batch_struct(result);
const auto x_ub = get_batch_struct(x);
GKO_DEVICE_NAMESPACE::batch_single_kernels::
batch_single_kernels::
copy_kernel<<<num_blocks, default_block_size, 0, exec->get_stream()>>>(
x_ub, result_ub);
}
Expand Down
16 changes: 6 additions & 10 deletions omp/base/batch_multi_vector_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void scale(std::shared_ptr<const DefaultExecutor> exec,
for (size_type batch = 0; batch < x->get_num_batch_items(); ++batch) {
const auto alpha_b = gko::batch::extract_batch_item(alpha_ub, batch);
const auto x_b = gko::batch::extract_batch_item(x_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::scale_kernel(alpha_b, x_b);
batch_single_kernels::scale_kernel(alpha_b, x_b);
}
}

Expand All @@ -55,8 +55,7 @@ void add_scaled(std::shared_ptr<const DefaultExecutor> exec,
const auto alpha_b = gko::batch::extract_batch_item(alpha_ub, batch);
const auto x_b = gko::batch::extract_batch_item(x_ub, batch);
const auto y_b = gko::batch::extract_batch_item(y_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::add_scaled_kernel(alpha_b,
x_b, y_b);
batch_single_kernels::add_scaled_kernel(alpha_b, x_b, y_b);
}
}

Expand All @@ -78,8 +77,7 @@ void compute_dot(std::shared_ptr<const DefaultExecutor> exec,
const auto res_b = gko::batch::extract_batch_item(res_ub, batch);
const auto x_b = gko::batch::extract_batch_item(x_ub, batch);
const auto y_b = gko::batch::extract_batch_item(y_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::compute_dot_product_kernel(
x_b, y_b, res_b);
batch_single_kernels::compute_dot_product_kernel(x_b, y_b, res_b);
}
}

Expand All @@ -101,8 +99,7 @@ void compute_conj_dot(std::shared_ptr<const DefaultExecutor> exec,
const auto res_b = gko::batch::extract_batch_item(res_ub, batch);
const auto x_b = gko::batch::extract_batch_item(x_ub, batch);
const auto y_b = gko::batch::extract_batch_item(y_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::
compute_conj_dot_product_kernel(x_b, y_b, res_b);
batch_single_kernels::compute_conj_dot_product_kernel(x_b, y_b, res_b);
}
}

Expand All @@ -121,8 +118,7 @@ void compute_norm2(std::shared_ptr<const DefaultExecutor> exec,
for (size_type batch = 0; batch < result->get_num_batch_items(); ++batch) {
const auto res_b = gko::batch::extract_batch_item(res_ub, batch);
const auto x_b = gko::batch::extract_batch_item(x_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::compute_norm2_kernel(x_b,
res_b);
batch_single_kernels::compute_norm2_kernel(x_b, res_b);
}
}

Expand All @@ -141,7 +137,7 @@ void copy(std::shared_ptr<const DefaultExecutor> exec,
for (size_type batch = 0; batch < x->get_num_batch_items(); ++batch) {
const auto result_b = gko::batch::extract_batch_item(result_ub, batch);
const auto x_b = gko::batch::extract_batch_item(x_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::copy_kernel(x_b, result_b);
batch_single_kernels::copy_kernel(x_b, result_b);
}
}

Expand Down
16 changes: 6 additions & 10 deletions reference/base/batch_multi_vector_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void scale(std::shared_ptr<const DefaultExecutor> exec,
for (size_type batch = 0; batch < x->get_num_batch_items(); ++batch) {
const auto alpha_b = batch::extract_batch_item(alpha_ub, batch);
const auto x_b = batch::extract_batch_item(x_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::scale_kernel(alpha_b, x_b);
batch_single_kernels::scale_kernel(alpha_b, x_b);
}
}

Expand All @@ -56,8 +56,7 @@ void add_scaled(std::shared_ptr<const DefaultExecutor> exec,
const auto alpha_b = batch::extract_batch_item(alpha_ub, batch);
const auto x_b = batch::extract_batch_item(x_ub, batch);
const auto y_b = batch::extract_batch_item(y_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::add_scaled_kernel(alpha_b,
x_b, y_b);
batch_single_kernels::add_scaled_kernel(alpha_b, x_b, y_b);
}
}

Expand All @@ -78,8 +77,7 @@ void compute_dot(std::shared_ptr<const DefaultExecutor> exec,
const auto res_b = batch::extract_batch_item(res_ub, batch);
const auto x_b = batch::extract_batch_item(x_ub, batch);
const auto y_b = batch::extract_batch_item(y_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::compute_dot_product_kernel(
x_b, y_b, res_b);
batch_single_kernels::compute_dot_product_kernel(x_b, y_b, res_b);
}
}

Expand All @@ -100,8 +98,7 @@ void compute_conj_dot(std::shared_ptr<const DefaultExecutor> exec,
const auto res_b = batch::extract_batch_item(res_ub, batch);
const auto x_b = batch::extract_batch_item(x_ub, batch);
const auto y_b = batch::extract_batch_item(y_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::
compute_conj_dot_product_kernel(x_b, y_b, res_b);
batch_single_kernels::compute_conj_dot_product_kernel(x_b, y_b, res_b);
}
}

Expand All @@ -119,8 +116,7 @@ void compute_norm2(std::shared_ptr<const DefaultExecutor> exec,
for (size_type batch = 0; batch < result->get_num_batch_items(); ++batch) {
const auto res_b = batch::extract_batch_item(res_ub, batch);
const auto x_b = batch::extract_batch_item(x_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::compute_norm2_kernel(x_b,
res_b);
batch_single_kernels::compute_norm2_kernel(x_b, res_b);
}
}

Expand All @@ -138,7 +134,7 @@ void copy(std::shared_ptr<const DefaultExecutor> exec,
for (size_type batch = 0; batch < x->get_num_batch_items(); ++batch) {
const auto result_b = batch::extract_batch_item(result_ub, batch);
const auto x_b = batch::extract_batch_item(x_ub, batch);
GKO_DEVICE_NAMESPACE::batch_single_kernels::copy_kernel(x_b, result_b);
batch_single_kernels::copy_kernel(x_b, result_b);
}
}

Expand Down

0 comments on commit b35d079

Please sign in to comment.