1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #9418 from borisfom:cuda9

CUDA9 build fixed, added detection (#9418)

* CUDA9 build fixed, added detection

* Replacing deprecated __shfl_xxx with __shfl_sync, fixing bogus CUDA9 warnings
This commit is contained in:
Boris Fomitchev
2017-08-24 00:11:44 -07:00
committed by Alexander Alekhin
parent d0509f6702
commit c48807c383
7 changed files with 51 additions and 11 deletions
@@ -47,6 +47,7 @@
#define OPENCV_CUDEV_UTIL_SATURATE_CAST_HPP
#include "../common.hpp"
#include "opencv2/core/private.cuda.hpp"
namespace cv { namespace cudev {
@@ -274,12 +275,21 @@ template <typename T, typename D> __device__ __forceinline__ D cast_fp16(T v);
template <> __device__ __forceinline__ float cast_fp16<short, float>(short v)
{
#if __CUDACC_VER_MAJOR__ >= 9
return float(*(__half*)&v);
#else
return __half2float(v);
#endif
}
template <> __device__ __forceinline__ short cast_fp16<float, short>(float v)
{
return (short)__float2half_rn(v);
#if __CUDACC_VER_MAJOR__ >= 9
__half h(v);
return *(short*)&v;
#else
return (short)__float2half_rn(v);
#endif
}
//! @}
@@ -56,8 +56,14 @@ namespace cv { namespace cudev {
#if CV_CUDEV_ARCH >= 300
// shfl
#if __CUDACC_VER_MAJOR__ >= 9
# define __shfl(x, y, z) __shfl_sync(0xFFFFFFFFU, x, y, z)
# define __shfl_xor(x, y, z) __shfl_xor_sync(0xFFFFFFFFU, x, y, z)
# define __shfl_up(x, y, z) __shfl_up_sync(0xFFFFFFFFU, x, y, z)
# define __shfl_down(x, y, z) __shfl_down_sync(0xFFFFFFFFU, x, y, z)
#endif
// shfl
__device__ __forceinline__ uchar shfl(uchar val, int srcLane, int width = warpSize)
{
return (uchar) __shfl((int) val, srcLane, width);
@@ -419,6 +425,10 @@ CV_CUDEV_SHFL_XOR_VEC_INST(float)
CV_CUDEV_SHFL_XOR_VEC_INST(double)
#undef CV_CUDEV_SHFL_XOR_VEC_INST
#undef __shfl
#undef __shfl_xor
#undef __shfl_up
#undef __shfl_down
#endif // CV_CUDEV_ARCH >= 300