Comments (11)
Just try out what is fastest and do that. Though I hope its the std::numeric_limits solution ;-)
from kokkos-kernels.
Kokkos::ArithTraits
needs to work on the GPU, so you can't use std::numeric_limits
if __CUDA_ARCH__
is defined. It could be that this works now, given how CUDA's constexpr
support has been evolving. However, you'll have to try it to be sure.
If std::numeric_limits
doesn't work, you could try this:
https://stackoverflow.com/questions/15514286/way-to-get-floating-point-special-values-in-cuda
from kokkos-kernels.
Actually, this is the code right now, so the CUDA part is already separate:
#ifdef __CUDA_ARCH__
return CUDART_NAN;
//return nan (); // this returns 0 ???
#else
// http://pubs.opengroup.org/onlinepubs/009696899/functions/nan.html
return strtod ("NAN", (char**) NULL);
#endif // __CUDA_ARCH__
So we only have to worry about the slow host code, which has no GPU restrictions.
from kokkos-kernels.
Suggest the strtod
only be called once to initialize a singleton:
#ifdef __CUDA_ARCH__
__device__ inline
double kokkos_kernels_nan_function() // whatever
{ return CUDART_NAN ; }
#else
inline
double kokkos_kernels_nan_function() // whatever
{ static double x = strtod("NAN",(char**)NULL); return x ; }
#endif
from kokkos-kernels.
This is quite similar to what Teuchos does. They also use a singleton, just a different initialization.
Any reason not to use the numeric_limits
quiet_NAN
to initialize the singleton instead of strtod
?
from kokkos-kernels.
Actually, std::numeric_limits<double>::quiet_NaN()
is constexpr
in C++11, so calling it directly might be faster than loading a singleton in that case.
from kokkos-kernels.
Could someone add me to this repository so I can assign this to myself?
from kokkos-kernels.
Ah this is Kokkos-Kernels totally overlooked this.
from kokkos-kernels.
std::numeric_limits
should work. We could even make ArithTraits::nan
constexpr
in the non-CUDA case (and eventually, even in the CUDA case, since CUDA looks like it's starting to get more constexpr
support).
Singletons could be bad if calling this in a thread-parallel context; we would want pthread_once
in that case.
from kokkos-kernels.
trilinos/Trilinos#1490 fixes this in Trilinos, including the addition of a performance test in the affected MiniTensor package to measure the difference.
#36 fixes this in the KokkosKernels develop branch.
They are separate since KokkosKernels is unlikely to promote into Trilinos in the near term, and MiniTensor needs this now.
from kokkos-kernels.
I submitted a trilinos/Trilinos#1490 review; thanks!
from kokkos-kernels.
Related Issues (20)
- BLAS test failures with non-ETI-only testing HOT 1
- GEMV unit test failures on Ponte Vecchio with oneMKL HOT 1
- Missing `Kokkos::fence` in `KokkosSparse_spmv_benchmark.cpp` HOT 1
- oneMKL `optimize_gemv` too slow for one-shot SpMV HOT 2
- Unecessary wait in oneMKL SpMV for 2023.2 and up HOT 1
- Remove references to `KokkosKernels_LINALG_OPT_LEVEL`
- Make sure `KokkosKernels_ENABLED_COMPONENTS` list of valid options is complete
- Necessity of both `KokkosKernels_ENABLED_COMPONENTS` and `KokkosKernels_ENABLE_...`? HOT 6
- axpby introduced deep_copies when alpha,beta are scalars HOT 2
- HIP -O0 -g: spgemm producess incorrect entries
- Trilinos nightly failure, ifpack2: spiluk errors with too few arguments to function call HOT 1
- One-based-ness of coloring is undocumented HOT 1
- Trilinos nightly failure, tpetra: no matching function for call to 'spadd_symbolic' HOT 1
- `KokkosBlas::Impl::MV_Reciprocal_Generic`: `g++-12` internal compiler failure with `-O3 -march=skylake-avx512` HOT 3
- rocSPARSE 3.0.2 for ROCm 6.0 breaking changes HOT 3
- Nightly test failures with cusolver tpl enabled, Cuda.svd_* unit tests HOT 6
- Nightly test failures, Cuda.svd_* and MKL DGEMM HOT 5
- Nightly test failures, builds with gcc/8.3.0 as host compiler: cc1plus: error with KokkosSparse::Impl::Sequential::TrsvWrap<...>::divide HOT 3
- Trilinos nightly failure, Cuda+UVM build, ifpack2/stokhos/sacado interaction in Ifpack2_LocalSparseTriangularSolver_def
- Lapack cuda.gesv_double test failing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kokkos-kernels.