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:
committed by
Alexander Alekhin
parent
d0509f6702
commit
c48807c383
@@ -58,6 +58,14 @@
|
||||
#ifdef HAVE_CUDA
|
||||
# include <cuda.h>
|
||||
# include <cuda_runtime.h>
|
||||
# if defined (__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
# include <cuda_fp16.h>
|
||||
# pragma GCC diagnostic pop
|
||||
# else
|
||||
# include <cuda_fp16.h>
|
||||
# endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) */
|
||||
# include <npp.h>
|
||||
# include "opencv2/core/cuda_stream_accessor.hpp"
|
||||
# include "opencv2/core/cuda/common.hpp"
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#include "opencv2/core/private.cuda.hpp"
|
||||
|
||||
#ifdef HAVE_NVCUVID
|
||||
#include <nvcuvid.h>
|
||||
#include <dynlink_nvcuvid.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user