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

Added CUDA __host__ __device__ with macro to Vector, Matrix, Limits, … #38

Merged
merged 3 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Imath/ImathFun.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER

template <class T>
constexpr inline T
IMATH_HOSTDEVICE constexpr inline T
abs (T a)
{
return (a > T (0)) ? a : -a;
Expand Down
156 changes: 78 additions & 78 deletions Imath/ImathLimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ IMATH_INTERNAL_NAMESPACE_HEADER_ENTER

template <class T> struct limits
{
static T min();
static T max();
static T smallest();
static T epsilon();
static bool isIntegral();
static bool isSigned();
IMATH_HOSTDEVICE static T min();
IMATH_HOSTDEVICE static T max();
IMATH_HOSTDEVICE static T smallest();
IMATH_HOSTDEVICE static T epsilon();
IMATH_HOSTDEVICE static bool isIntegral();
IMATH_HOSTDEVICE static bool isSigned();
};

//---------------
Expand All @@ -127,122 +127,122 @@ template <class T> struct limits

template <> struct limits<char>
{
static char min() { return CHAR_MIN; }
static char max() { return CHAR_MAX; }
static char smallest() { return 1; }
static char epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return (char) ~0 < 0; }
IMATH_HOSTDEVICE static char min() { return CHAR_MIN; }
IMATH_HOSTDEVICE static char max() { return CHAR_MAX; }
IMATH_HOSTDEVICE static char smallest() { return 1; }
IMATH_HOSTDEVICE static char epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return (char) ~0 < 0; }
};

template <> struct limits<signed char>
{
static signed char min() { return SCHAR_MIN; }
static signed char max() { return SCHAR_MAX; }
static signed char smallest() { return 1; }
static signed char epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static signed char min() { return SCHAR_MIN; }
IMATH_HOSTDEVICE static signed char max() { return SCHAR_MAX; }
IMATH_HOSTDEVICE static signed char smallest() { return 1; }
IMATH_HOSTDEVICE static signed char epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

template <> struct limits<unsigned char>
{
static unsigned char min() { return 0; }
static unsigned char max() { return UCHAR_MAX; }
static unsigned char smallest() { return 1; }
static unsigned char epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return false; }
IMATH_HOSTDEVICE static unsigned char min() { return 0; }
IMATH_HOSTDEVICE static unsigned char max() { return UCHAR_MAX; }
IMATH_HOSTDEVICE static unsigned char smallest() { return 1; }
IMATH_HOSTDEVICE static unsigned char epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return false; }
};

template <> struct limits<short>
{
static short min() { return SHRT_MIN; }
static short max() { return SHRT_MAX; }
static short smallest() { return 1; }
static short epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static short min() { return SHRT_MIN; }
IMATH_HOSTDEVICE static short max() { return SHRT_MAX; }
IMATH_HOSTDEVICE static short smallest() { return 1; }
IMATH_HOSTDEVICE static short epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

template <> struct limits<unsigned short>
{
static unsigned short min() { return 0; }
static unsigned short max() { return USHRT_MAX; }
static unsigned short smallest() { return 1; }
static unsigned short epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return false; }
IMATH_HOSTDEVICE static unsigned short min() { return 0; }
IMATH_HOSTDEVICE static unsigned short max() { return USHRT_MAX; }
IMATH_HOSTDEVICE static unsigned short smallest() { return 1; }
IMATH_HOSTDEVICE static unsigned short epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return false; }
};

template <> struct limits<int>
{
static int min() { return INT_MIN; }
static int max() { return INT_MAX; }
static int smallest() { return 1; }
static int epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static int min() { return INT_MIN; }
IMATH_HOSTDEVICE static int max() { return INT_MAX; }
IMATH_HOSTDEVICE static int smallest() { return 1; }
IMATH_HOSTDEVICE static int epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

template <> struct limits<unsigned int>
{
static unsigned int min() { return 0; }
static unsigned int max() { return UINT_MAX; }
static unsigned int smallest() { return 1; }
static unsigned int epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return false; }
IMATH_HOSTDEVICE static unsigned int min() { return 0; }
IMATH_HOSTDEVICE static unsigned int max() { return UINT_MAX; }
IMATH_HOSTDEVICE static unsigned int smallest() { return 1; }
IMATH_HOSTDEVICE static unsigned int epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return false; }
};

template <> struct limits<long>
{
static long min() { return LONG_MIN; }
static long max() { return LONG_MAX; }
static long smallest() { return 1; }
static long epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static long min() { return LONG_MIN; }
IMATH_HOSTDEVICE static long max() { return LONG_MAX; }
IMATH_HOSTDEVICE static long smallest() { return 1; }
IMATH_HOSTDEVICE static long epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

template <> struct limits<unsigned long>
{
static unsigned long min() { return 0; }
static unsigned long max() { return ULONG_MAX; }
static unsigned long smallest() { return 1; }
static unsigned long epsilon() { return 1; }
static bool isIntegral() { return true; }
static bool isSigned() { return false; }
IMATH_HOSTDEVICE static unsigned long min() { return 0; }
IMATH_HOSTDEVICE static unsigned long max() { return ULONG_MAX; }
IMATH_HOSTDEVICE static unsigned long smallest() { return 1; }
IMATH_HOSTDEVICE static unsigned long epsilon() { return 1; }
IMATH_HOSTDEVICE static bool isIntegral() { return true; }
IMATH_HOSTDEVICE static bool isSigned() { return false; }
};

template <> struct limits<float>
{
static float min() { return -FLT_MAX; }
static float max() { return FLT_MAX; }
static float smallest() { return FLT_MIN; }
static float epsilon() { return FLT_EPSILON; }
static bool isIntegral() { return false; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static float min() { return -FLT_MAX; }
IMATH_HOSTDEVICE static float max() { return FLT_MAX; }
IMATH_HOSTDEVICE static float smallest() { return FLT_MIN; }
IMATH_HOSTDEVICE static float epsilon() { return FLT_EPSILON; }
IMATH_HOSTDEVICE static bool isIntegral() { return false; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

template <> struct limits<double>
{
static double min() { return -DBL_MAX; }
static double max() { return DBL_MAX; }
static double smallest() { return DBL_MIN; }
static double epsilon() { return DBL_EPSILON; }
static bool isIntegral() { return false; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static double min() { return -DBL_MAX; }
IMATH_HOSTDEVICE static double max() { return DBL_MAX; }
IMATH_HOSTDEVICE static double smallest() { return DBL_MIN; }
IMATH_HOSTDEVICE static double epsilon() { return DBL_EPSILON; }
IMATH_HOSTDEVICE static bool isIntegral() { return false; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

template <> struct limits<long double>
{
static long double min() { return -LDBL_MAX; }
static long double max() { return LDBL_MAX; }
static long double smallest() { return LDBL_MIN; }
static long double epsilon() { return LDBL_EPSILON; }
static bool isIntegral() { return false; }
static bool isSigned() { return true; }
IMATH_HOSTDEVICE static long double min() { return -LDBL_MAX; }
IMATH_HOSTDEVICE static long double max() { return LDBL_MAX; }
IMATH_HOSTDEVICE static long double smallest() { return LDBL_MIN; }
IMATH_HOSTDEVICE static long double epsilon() { return LDBL_EPSILON; }
IMATH_HOSTDEVICE static bool isIntegral() { return false; }
IMATH_HOSTDEVICE static bool isSigned() { return true; }
};

IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
Expand Down
4 changes: 2 additions & 2 deletions Imath/ImathMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ sinx_over_x (T x)
//--------------------------------------------------------------------------

template <class T>
inline bool
IMATH_HOSTDEVICE inline bool
equalWithAbsError (T x1, T x2, T e)
{
return ((x1 > x2) ? x1 - x2 : x2 - x1) <= e;
}

template <class T>
inline bool
IMATH_HOSTDEVICE inline bool
equalWithRelError (T x1, T x2, T e)
{
return ((x1 > x2) ? x1 - x2 : x2 - x1) <= e * ((x1 > 0) ? x1 : -x1);
Expand Down
Loading