Skip to content

Commit

Permalink
add missing headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Jan 25, 2024
1 parent f2d94e1 commit 4844105
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/targets/cuda/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if defined(__NVCC__)

#include <math_helper.cuh>

#else

#include "../generic/math_helper.h"

#endif
29 changes: 29 additions & 0 deletions include/targets/generic/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <cmath>

namespace quda {

inline float abs(const float a) { return fabs(a); }
inline double abs(const double a) { return fabs(a); }
template <typename T> inline T sqrt(const T a) { return ::sqrt(a); }
template <typename T> inline T exp(const T a) { return ::exp(a); }
template <typename T> inline T log(const T a) { return ::log(a); }
template <typename T> inline T sin(const T a) { return ::sin(a); }
template <typename T> inline T cos(const T a) { return ::cos(a); }
template <typename T> inline T sinh(const T a) { return ::sinh(a); }
template <typename T> inline T cosh(const T a) { return ::cosh(a); }
template <typename T> inline T max(const T a, const T b) { return a > b ? a : b; }
template <typename T> inline T min(const T a, const T b) { return a < b ? a : b; }
template <typename T> inline void sincos(const T a, T *s, T *c) { ::sincos(a, s, c); }
template <typename T> inline void sincospi(const T a, T *s, T *c) { ::sincos(a * static_cast<T>(M_PI), s, c); }
template <typename T> inline T sinpi(const T a) { return ::sin(a * static_cast<float>(M_PI)); }
template <typename T> inline T cospi(const T a) { return ::cos(a * static_cast<float>(M_PI)); }
template <typename T> inline T rsqrt(const T a) { return static_cast<T>(1.0) / ::sqrt(a); }
//template <typename T> inline T rsqrt(T a) { return ::rsqrt(a); }
template <typename T> inline T pow(const T a, const T b) { return ::pow(a, b); }
template <typename T> inline T pow(const T a, const int b) { return ::pow(a, b); }
template <typename T> inline T fpow(const T a, const int b) { return ::pow(a, b); }
inline float fdividef(const float a, const float b) { return a / b; }

}
9 changes: 9 additions & 0 deletions include/targets/hip/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if defined(__HIP__)

#include <math_helper.cuh>

#else

#include "../generic/math_helper.h"

#endif
1 change: 1 addition & 0 deletions include/targets/sycl/math_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <math_helper.cuh>

0 comments on commit 4844105

Please sign in to comment.