Skip to content

Commit

Permalink
Merge branch '750' into 'master'
Browse files Browse the repository at this point in the history
Resolve "直接法の線型方程式ソルバーのバグ修正"

Closes #750

See merge request ricos/monolish!510
  • Loading branch information
fockl committed Aug 30, 2024
2 parents 0a2df91 + 1c4cb6b commit d7b7fd3
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Unreleased
### Fixed
- Fix benchmark result token <https://gitlab.ritc.jp/ricos/monolish/-/merge_requests/502> <https://github.com/ricosjp/monolish/issues/733>
- Fix set_ptr bug <https://gitlab.ritc.jp/ricos/monolish/-/merge_requests/508> <https://github.com/ricosjp/monolish/issues/741>
- Fix linear solver bug for non-symmetric matrix <https://gitlab.ritc.jp/ricos/monolish/-/merge_requests/510> <https://github.com/ricosjp/monolish/issues/750>

### Changed
- Update cuda version of allgebra <https://gitlab.ritc.jp/ricos/monolish/-/merge_requests/506> <https://github.com/ricosjp/monolish/issues/739>
Expand Down
8 changes: 6 additions & 2 deletions src/internal/lapack/getrs/dense_double_getrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int internal::lapack::getrs(const matrix::Dense<double> &A, vector<double> &B,
const double *Ad = A.data();
double *Bd = B.data();
const int *ipivd = ipiv.data();
const char trans = 'N';
const char trans = 'T';

if (A.get_device_mem_stat() == true && B.get_device_mem_stat() == true) {
#if MONOLISH_USE_NVIDIA_GPU
Expand All @@ -42,7 +42,11 @@ int internal::lapack::getrs(const matrix::Dense<double> &A, vector<double> &B,

#pragma omp target data use_device_ptr(Ad, ipivd, Bd, devinfod)
{
internal::check_CUDA(cusolverDnDgetrs(h, CUBLAS_OP_N, M, K, Ad, N, ipivd,
auto cublas_trans = CUBLAS_OP_N;
if (trans == 'T') {
cublas_trans = CUBLAS_OP_T;
}
internal::check_CUDA(cusolverDnDgetrs(h, cublas_trans, M, K, Ad, N, ipivd,
Bd, M, devinfod));
}

Expand Down
8 changes: 6 additions & 2 deletions src/internal/lapack/getrs/dense_float_getrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int internal::lapack::getrs(const matrix::Dense<float> &A, vector<float> &B,
const float *Ad = A.data();
float *Bd = B.data();
const int *ipivd = ipiv.data();
const char trans = 'N';
const char trans = 'T';

if (A.get_device_mem_stat() == true && B.get_device_mem_stat() == true) {
#if MONOLISH_USE_NVIDIA_GPU
Expand All @@ -42,7 +42,11 @@ int internal::lapack::getrs(const matrix::Dense<float> &A, vector<float> &B,

#pragma omp target data use_device_ptr(Ad, ipivd, Bd, devinfod)
{
internal::check_CUDA(cusolverDnSgetrs(h, CUBLAS_OP_N, M, K, Ad, N, ipivd,
auto cublas_trans = CUBLAS_OP_N;
if (trans == 'T') {
cublas_trans = CUBLAS_OP_T;
}
internal::check_CUDA(cusolverDnSgetrs(h, cublas_trans, M, K, Ad, N, ipivd,
Bd, M, devinfod));
}

Expand Down
4 changes: 4 additions & 0 deletions test/equation/dense_lu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ sxat:

run_cpu:
./$(FUNC)_cpu.out ../../test.mtx 1
./$(FUNC)_cpu.out ../../test2.mtx 1

run_gpu:
$(PROFILER)./$(FUNC)_gpu.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_gpu.out ../../test2.mtx 1

run_a64fx:
$(PROFILER)./$(FUNC)_a64fx.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_a64fx.out ../../test2.mtx 1

run_sxat:
$(PROFILER)./$(FUNC)_sxat.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_sxat.out ../../test2.mtx 1

clean:
- rm *.out
4 changes: 4 additions & 0 deletions test/equation/sparse_ic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ sxat:

run_cpu:
./$(FUNC)_cpu.out ../../test.mtx 1
./$(FUNC)_cpu.out ../../test2.mtx 1

run_gpu:
$(PROFILER)./$(FUNC)_gpu.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_gpu.out ../../test2.mtx 1

run_a64fx:
$(PROFILER)./$(FUNC)_a64fx.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_a64fx.out ../../test2.mtx 1

run_sxat:
$(PROFILER)./$(FUNC)_sxat.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_sxat.out ../../test2.mtx 1

clean:
- rm *.out
4 changes: 4 additions & 0 deletions test/equation/sparse_ilu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ sxat:

run_cpu:
./$(FUNC)_cpu.out ../../test.mtx 1
./$(FUNC)_cpu.out ../../test2.mtx 1

run_gpu:
$(PROFILER)./$(FUNC)_gpu.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_gpu.out ../../test2.mtx 1

run_a64fx:
$(PROFILER)./$(FUNC)_a64fx.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_a64fx.out ../../test2.mtx 1

run_sxat:
$(PROFILER)./$(FUNC)_sxat.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_sxat.out ../../test2.mtx 1

clean:
- rm *.out
4 changes: 4 additions & 0 deletions test/equation/sparse_qr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ sxat:

run_cpu:
./$(FUNC)_cpu.out ../../test.mtx 1
./$(FUNC)_cpu.out ../../test2.mtx 1

run_gpu:
$(PROFILER)./$(FUNC)_gpu.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_gpu.out ../../test2.mtx 1

run_a64fx:
$(PROFILER)./$(FUNC)_a64fx.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_a64fx.out ../../test2.mtx 1

run_sxat:
$(PROFILER)./$(FUNC)_sxat.out ../../test.mtx 1
$(PROFILER)./$(FUNC)_sxat.out ../../test2.mtx 1

clean:
- rm *.out
9 changes: 9 additions & 0 deletions test/test2.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%%MatrixMarket matrix coordinate real general
3 3 7
1 1 2
1 2 1
2 1 -1
2 2 2
2 3 -1
3 2 1
3 3 2
14 changes: 7 additions & 7 deletions test/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ bool ans_check(const std::string &func, double result, double ans, double tol) {
}

if (err < tol) {
std::cout << func << "(" << get_type<T>() << ")" << std::flush;
std::cout << ": pass" << std::endl;
// std::cout << func << "(" << get_type<T>() << ")" << std::flush;
// std::cout << ": pass" << std::endl;
return true;
} else {
std::cout << "Error!!" << std::endl;
Expand Down Expand Up @@ -104,8 +104,8 @@ bool ans_check(const std::string &func, const T *result, const T *ans, int size,
}

if (check) {
std::cout << func << "(" << get_type<T>() << ")" << std::flush;
std::cout << ": pass" << std::endl;
// std::cout << func << "(" << get_type<T>() << ")" << std::flush;
// std::cout << ": pass" << std::endl;
return check;
} else {
std::cout << "Error!!" << std::endl;
Expand Down Expand Up @@ -144,9 +144,9 @@ bool ans_check(const std::string &func, const std::string &type,
}

if (check) {
std::cout << func << "(" << get_type<T>() << "," << type << ")"
<< std::flush;
std::cout << ": pass" << std::endl;
// std::cout << func << "(" << get_type<T>() << "," << type << ")"
// << std::flush;
// std::cout << ": pass" << std::endl;
return check;
} else {
std::cout << "Error!!" << std::endl;
Expand Down

0 comments on commit d7b7fd3

Please sign in to comment.