Skip to content

Commit 432fe5a

Browse files
yhmtsaipratikvn
andcommitted
add get_compute_capability in cudaExecutor
Co-authored-by: Pratik Nayak <pratikvn@protonmail.com>
1 parent 61107dd commit 432fe5a

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

common/cuda_hip/matrix/coo_kernels.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ void spmv2(std::shared_ptr<const DefaultExecutor> exec,
276276
GKO_NOT_SUPPORTED(c);
277277
} else
278278
#else
279-
auto compute_capability = as<CudaExecutor>(exec)->get_major_version() * 10 +
280-
as<CudaExecutor>(exec)->get_minor_version();
279+
const auto compute_capability =
280+
as<CudaExecutor>(exec)->get_compute_capability();
281281
if (compute_capability < 70 &&
282282
std::is_same_v<remove_complex<ValueType>, half>) {
283283
GKO_NOT_SUPPORTED(c);
@@ -338,8 +338,8 @@ void advanced_spmv2(std::shared_ptr<const DefaultExecutor> exec,
338338
GKO_NOT_SUPPORTED(c);
339339
} else
340340
#else
341-
auto compute_capability = as<CudaExecutor>(exec)->get_major_version() * 10 +
342-
as<CudaExecutor>(exec)->get_minor_version();
341+
const auto compute_capability =
342+
as<CudaExecutor>(exec)->get_compute_capability();
343343
if (compute_capability < 70 &&
344344
std::is_same_v<remove_complex<ValueType>, half>) {
345345
GKO_NOT_SUPPORTED(c);

common/cuda_hip/matrix/csr_kernels.template.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,8 +2097,7 @@ bool load_balance_spmv(std::shared_ptr<const DefaultExecutor> exec,
20972097
return false;
20982098
} else
20992099
#else
2100-
auto compute_capability = as<CudaExecutor>(exec)->get_major_version() * 10 +
2101-
as<CudaExecutor>(exec)->get_minor_version();
2100+
auto compute_capability = as<CudaExecutor>(exec)->get_compute_capability();
21022101
if (compute_capability < 70 &&
21032102
std::is_same_v<remove_complex<OutputValueType>, half>) {
21042103
return false;

common/cuda_hip/matrix/ell_kernels.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ void abstract_spmv(syn::value_list<int, info>,
272272
sizeof(remove_complex<arithmetic_type>) == sizeof(bfloat16);
273273
constexpr bool atomic_bfloat16_out =
274274
atomic && sizeof(remove_complex<OutputValueType>) == sizeof(bfloat16);
275-
auto compute_capability = as<CudaExecutor>(exec)->get_major_version() * 10 +
276-
as<CudaExecutor>(exec)->get_minor_version();
275+
const auto compute_capability =
276+
as<CudaExecutor>(exec)->get_compute_capability();
277277
if (num_thread_per_worker != 1 && (shared_half || atomic_half_out) &&
278278
compute_capability < 70) {
279279
GKO_KERNEL_NOT_FOUND;

common/cuda_hip/solver/idr_kernels.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,8 @@ void update_g_and_u(std::shared_ptr<const DefaultExecutor> exec,
460460
GKO_NOT_SUPPORTED(alpha);
461461
} else
462462
#else
463-
auto compute_capability =
464-
as<CudaExecutor>(exec)->get_major_version() * 10 +
465-
as<CudaExecutor>(exec)->get_minor_version();
463+
const auto compute_capability =
464+
as<CudaExecutor>(exec)->get_compute_capability();
466465
if (compute_capability < 70 &&
467466
std::is_same_v<remove_complex<ValueType>, half>) {
468467
GKO_NOT_SUPPORTED(alpha);
@@ -531,9 +530,8 @@ void update_m(std::shared_ptr<const DefaultExecutor> exec, const size_type nrhs,
531530
GKO_NOT_SUPPORTED(m_i);
532531
} else
533532
#else
534-
auto compute_capability =
535-
as<CudaExecutor>(exec)->get_major_version() * 10 +
536-
as<CudaExecutor>(exec)->get_minor_version();
533+
const auto compute_capability =
534+
as<CudaExecutor>(exec)->get_compute_capability();
537535
if (compute_capability < 70 &&
538536
std::is_same_v<remove_complex<ValueType>, half>) {
539537
GKO_NOT_SUPPORTED(m_i);

include/ginkgo/core/base/executor.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
1+
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

@@ -1656,6 +1656,14 @@ class CudaExecutor : public detail::ExecutorBase<CudaExecutor>,
16561656
return this->get_exec_info().minor;
16571657
}
16581658

1659+
/**
1660+
* Get the compute capability
1661+
*/
1662+
int get_compute_capability() const noexcept
1663+
{
1664+
return this->get_major_version() * 10 + this->get_minor_version();
1665+
}
1666+
16591667
/**
16601668
* Get the cublas handle for this executor
16611669
*

0 commit comments

Comments
 (0)