fixed build for CARMA platform
This commit is contained in:
@@ -45,8 +45,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#include <cuda_runtime.h>
|
||||
#include <npp.h>
|
||||
|
||||
#define CUDART_MINIMUM_REQUIRED_VERSION 4010
|
||||
@@ -394,18 +393,6 @@ void cv::gpu::DeviceInfo::queryMemory(size_t& free_memory, size_t& total_memory)
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class T> void getCudaAttribute(T *attribute, CUdevice_attribute device_attribute, int device)
|
||||
{
|
||||
*attribute = T();
|
||||
//CUresult error = CUDA_SUCCESS;// = cuDeviceGetAttribute( attribute, device_attribute, device ); why link erros under ubuntu??
|
||||
CUresult error = cuDeviceGetAttribute( attribute, device_attribute, device );
|
||||
if( CUDA_SUCCESS == error )
|
||||
return;
|
||||
|
||||
printf("Driver API error = %04d\n", error);
|
||||
cv::gpu::error("driver API error", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
int convertSMVer2Cores(int major, int minor)
|
||||
{
|
||||
// Defines for GPU Architecture types (using the SM version to determine the # of cores per SM
|
||||
@@ -466,17 +453,6 @@ void cv::gpu::printCudaDeviceInfo(int device)
|
||||
convertSMVer2Cores(prop.major, prop.minor) * prop.multiProcessorCount);
|
||||
printf(" GPU Clock Speed: %.2f GHz\n", prop.clockRate * 1e-6f);
|
||||
|
||||
// This is not available in the CUDA Runtime API, so we make the necessary calls the driver API to support this for output
|
||||
int memoryClock, memBusWidth, L2CacheSize;
|
||||
getCudaAttribute<int>( &memoryClock, CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE, dev );
|
||||
getCudaAttribute<int>( &memBusWidth, CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH, dev );
|
||||
getCudaAttribute<int>( &L2CacheSize, CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE, dev );
|
||||
|
||||
printf(" Memory Clock rate: %.2f Mhz\n", memoryClock * 1e-3f);
|
||||
printf(" Memory Bus Width: %d-bit\n", memBusWidth);
|
||||
if (L2CacheSize)
|
||||
printf(" L2 Cache Size: %d bytes\n", L2CacheSize);
|
||||
|
||||
printf(" Max Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d,%d), 3D=(%d,%d,%d)\n",
|
||||
prop.maxTexture1D, prop.maxTexture2D[0], prop.maxTexture2D[1],
|
||||
prop.maxTexture3D[0], prop.maxTexture3D[1], prop.maxTexture3D[2]);
|
||||
|
@@ -44,11 +44,13 @@
|
||||
#include "opencv2/core/opengl_interop.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
||||
#include "gl_core_3_1.hpp"
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "gl_core_3_1.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#include <cuda_gl_interop.h>
|
||||
#ifdef HAVE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#include <cuda_gl_interop.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
@@ -61,24 +63,24 @@ namespace
|
||||
void throw_nogl() { CV_Error(CV_OpenGlNotSupported, "The library is compiled without OpenGL support"); }
|
||||
#else
|
||||
void throw_nogl() { CV_Error(CV_OpenGlApiCallError, "OpenGL context doesn't exist"); }
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CUDA
|
||||
void throw_nocuda() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); }
|
||||
#else
|
||||
void throw_nocuda() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
||||
#ifndef HAVE_CUDA
|
||||
void throw_nocuda() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); }
|
||||
#else
|
||||
void throw_nocuda() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
||||
#if defined(__GNUC__)
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
void ___cudaSafeCall(cudaError_t err, const char* file, const int line, const char* func = "")
|
||||
{
|
||||
if (cudaSuccess != err)
|
||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ___cudaSafeCall(cudaError_t err, const char* file, const int line, const char* func = "")
|
||||
{
|
||||
if (cudaSuccess != err)
|
||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -139,11 +141,16 @@ namespace
|
||||
|
||||
void cv::gpu::setGlDevice(int device)
|
||||
{
|
||||
#if !defined(HAVE_CUDA) || defined(CUDA_DISABLER)
|
||||
#ifndef HAVE_OPENGL
|
||||
(void) device;
|
||||
throw_nocuda();
|
||||
throw_nogl();
|
||||
#else
|
||||
cudaSafeCall( cudaGLSetGLDevice(device) );
|
||||
#if !defined(HAVE_CUDA) || defined(CUDA_DISABLER)
|
||||
(void) device;
|
||||
throw_nocuda();
|
||||
#else
|
||||
cudaSafeCall( cudaGLSetGLDevice(device) );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user