Skip to content

Commit 414de89

Browse files
committed
fix warnings
1 parent 8da182a commit 414de89

4 files changed

Lines changed: 23 additions & 24 deletions

File tree

common/unified/matrix/csr_kernels.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ void row_wise_absolute_sum(std::shared_ptr<const DefaultExecutor> exec,
326326
sum_ptr[row] += abs(value_ptr[k]);
327327
}
328328
},
329-
sum.get_num_elems(), orig->get_const_row_ptrs(),
330-
orig->get_const_values(), sum.get_data());
329+
sum.get_size(), orig->get_const_row_ptrs(), orig->get_const_values(),
330+
sum.get_data());
331331
}
332332

333333
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(

hip/solver/common_trs_kernels.hip.hpp

Lines changed: 15 additions & 16 deletions
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

@@ -45,11 +45,12 @@ struct SolveStruct : gko::solver::SolveStruct {
4545
csrsv2Info_t solve_info;
4646
hipsparseSolvePolicy_t policy;
4747
hipsparseMatDescr_t factor_descr;
48-
int factor_work_size;
48+
array<char> factor_work_array;
4949
void* factor_work_vec;
50-
SolveStruct(bool is_upper, bool unit_diag)
50+
SolveStruct(std::shared_ptr<const Executor> exec, bool is_upper,
51+
bool unit_diag)
52+
: factor_work_array{exec}
5153
{
52-
factor_work_vec = nullptr;
5354
GKO_ASSERT_NO_HIPSPARSE_ERRORS(hipsparseCreateMatDescr(&factor_descr));
5455
GKO_ASSERT_NO_HIPSPARSE_ERRORS(
5556
hipsparseSetMatIndexBase(factor_descr, HIPSPARSE_INDEX_BASE_ZERO));
@@ -79,10 +80,6 @@ struct SolveStruct : gko::solver::SolveStruct {
7980
if (solve_info) {
8081
hipsparseDestroyCsrsv2Info(solve_info);
8182
}
82-
if (factor_work_vec != nullptr) {
83-
hipFree(factor_work_vec);
84-
factor_work_vec = nullptr;
85-
}
8683
}
8784
};
8885

@@ -114,29 +111,31 @@ void generate_kernel(std::shared_ptr<const HipExecutor> exec,
114111
return;
115112
}
116113
if (sparselib::is_supported<ValueType, IndexType>::value) {
117-
solve_struct =
118-
std::make_shared<solver::hip::SolveStruct>(is_upper, unit_diag);
114+
solve_struct = std::make_shared<solver::hip::SolveStruct>(
115+
exec, is_upper, unit_diag);
119116
if (auto hip_solve_struct =
120117
std::dynamic_pointer_cast<solver::hip::SolveStruct>(
121118
solve_struct)) {
122119
auto handle = exec->get_sparselib_handle();
123120

124121
{
125122
sparselib::pointer_mode_guard pm_guard(handle);
123+
int factor_work_size{};
126124
sparselib::csrsv2_buffer_size(
127125
handle, SPARSELIB_OPERATION_NON_TRANSPOSE,
128126
matrix->get_size()[0], matrix->get_num_stored_elements(),
129127
hip_solve_struct->factor_descr, matrix->get_const_values(),
130128
matrix->get_const_row_ptrs(), matrix->get_const_col_idxs(),
131-
hip_solve_struct->solve_info,
132-
&hip_solve_struct->factor_work_size);
129+
hip_solve_struct->solve_info, &factor_work_size);
133130

134131
// allocate workspace
135-
if (hip_solve_struct->factor_work_vec != nullptr) {
136-
exec->free(hip_solve_struct->factor_work_vec);
132+
if (hip_solve_struct->factor_work_array.get_size() <
133+
factor_work_size) {
134+
hip_solve_struct->factor_work_array.resize_and_reset(
135+
factor_work_size);
136+
hip_solve_struct->factor_work_vec =
137+
hip_solve_struct->factor_work_array.get_data();
137138
}
138-
hip_solve_struct->factor_work_vec =
139-
exec->alloc<void*>(hip_solve_struct->factor_work_size);
140139

141140
sparselib::csrsv2_analysis(
142141
handle, SPARSELIB_OPERATION_NON_TRANSPOSE,

hip/test/base/hip_executor.hip.cpp

Lines changed: 3 additions & 3 deletions
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

@@ -51,7 +51,7 @@ class ExampleOperation : public gko::Operation {
5151

5252
void run(std::shared_ptr<const gko::HipExecutor>) const override
5353
{
54-
hipGetDevice(&value);
54+
GKO_ASSERT_NO_HIP_ERRORS(hipGetDevice(&value));
5555
}
5656

5757
int& value;
@@ -124,7 +124,7 @@ TEST_F(HipExecutor, CanInstantiateTwoExecutorsOnOneDevice)
124124
TEST_F(HipExecutor, MasterKnowsNumberOfDevices)
125125
{
126126
int count = 0;
127-
hipGetDeviceCount(&count);
127+
GKO_ASSERT_NO_HIP_ERRORS(hipGetDeviceCount(&count));
128128

129129
auto num_devices = gko::HipExecutor::get_num_devices();
130130

hip/test/base/scoped_device_id.hip.cpp

Lines changed: 3 additions & 3 deletions
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

@@ -30,7 +30,7 @@ TEST_F(ScopedDeviceIdGuard, SetsId)
3030
gko::detail::hip_scoped_device_id_guard g{new_device_id};
3131

3232
int device_id;
33-
hipGetDevice(&device_id);
33+
GKO_ASSERT_NO_HIP_ERRORS(hipGetDevice(&device_id));
3434
ASSERT_EQ(device_id, new_device_id);
3535
}
3636

@@ -45,7 +45,7 @@ TEST_F(ScopedDeviceIdGuard, ResetsId)
4545
}
4646

4747
int device_id;
48-
hipGetDevice(&device_id);
48+
GKO_ASSERT_NO_HIP_ERRORS(hipGetDevice(&device_id));
4949
ASSERT_EQ(device_id, old_device_id);
5050
}
5151

0 commit comments

Comments
 (0)