Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more precisions #198

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open

Support more precisions #198

wants to merge 46 commits into from

Conversation

KowerKoint
Copy link
Contributor

IEEE754 float16(F16)とbinary16(F16)をサポートします.

テストとPythonバインドは未対応です.

apt-get install -y gcc-13 g++-13 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 && \
apt-get install -y --no-install-recommends \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<stdfloat>のためにg++13が必要

Comment on lines +20 to +31
if(NOT DEFINED SCALUQ_FLOAT16)
set(SCALUQ_FLOAT16 OFF)
endif(NOT DEFINED SCALUQ_FLOAT16)
if(NOT DEFINED SCALUQ_FLOAT32)
set(SCALUQ_FLOAT32 ON)
endif(NOT DEFINED SCALUQ_FLOAT32)
if(NOT DEFINED SCALUQ_FLOAT64)
set(SCALUQ_FLOAT64 ON)
endif(NOT DEFINED SCALUQ_FLOAT64)
if(NOT DEFINED SCALUQ_BFLOAT16)
set(SCALUQ_BFLOAT16 OFF)
endif(NOT DEFINED SCALUQ_BFLOAT16)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

各精度コンパイルに含めるかを選択できるようになっていて,デフォルトではF32,F64がONになっています.

Comment on lines -103 to -104
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang"))
# Standard
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCCしかサポートしていないので削除

if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang"))
# Standard
# Standard
if(SCALUQ_USE_CUDA)
target_compile_features(scaluq PUBLIC cxx_std_20)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVCCはC++23に対応していない

using StdComplex = std::complex<Fp>;
template <std::floating_point Fp>
using Complex = Kokkos::complex<Fp>;
using StdComplex = std::complex<double>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ユーザー向けはdouble std::complex<double>だけ使ってもらうことにしたので,Complexはinternalへ

Comment on lines +22 to +23
using ComplexMatrix = Eigen::Matrix<StdComplex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
using SparseComplexMatrix = Eigen::SparseMatrix<StdComplex, Eigen::RowMajor>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こいつらはユーザー向けなのであとでinternalの外へ移動


namespace scaluq {
enum class Precision { F16, F32, F64, BF16 };
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`template std::floating_pointをやめてこのenumをテンプレートで指定することになります

template <typename T>
struct IsFloatingPoint : public std::false_type {};
#ifdef SCALUQ_FLOAT16
#ifdef SCALUQ_USE_CUDA
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

種類 CPU CUDA
F16 std::float16_t __half
F32 std::float32_t short
F16 std::float64_t double
F16 std::bfloat16_t __nv_bfloat16

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kokkos::Complexstd::floating_pointコンセプトが条件になっていて,残念ながらCUDA独自の__half __nv_bfloat16は置けないので自作し直した:innocent:

@KowerKoint
Copy link
Contributor Author

テストが通ってREADMEも整備できたので、 #200 の分をここで手動でマージします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant