Subversion

gpucv

[/] [experimental/] [trunk/] [gpucv/] [src/] [lib/] [GPUCVCuda/] [cuda_misc.cpp] - Rev 271 Go to most recent revision

Compare with Previous - Blame


#include <GPUCVCuda/config.h>
#if _GPUCV_COMPILE_CUDA
#include <GPUCV/misc.h>
#include <GPUCVCuda/cuda_misc.h>
#include <GPUCVCuda/GPU_NVIDIA_CUDA.h>


/*
*   \author Yannick Allusse
*/

 
int  cvgcuInit(bool InitGLContext/*=true*/, bool isMultiThread/*=false*/)
{
        if(!cvgInit(InitGLContext, isMultiThread))
                return false;

        //init cuda
        //cutwrDeviceInit();//must be 0(beta 1.1)

        int DeviceCount = 0;
        gcudaGetDeviceCount(&DeviceCount);
        if(DeviceCount ==0)
        {
                GPUCV_NOTICE("cvgcuInit()=>No compatible device, must run in emulation mode");
                return false;
        }
        else
        {
                GPUCV_NOTICE(DeviceCount << " CUDA capable GPU found");
        }

        GPU_NVIDIA_CUDA * CudaGpu = NULL;
        for (int i =0; i < DeviceCount; i++)
        {
                //add CUDA gpu to list of GPUs
                CudaGpu = new GPU_NVIDIA_CUDA();
                CudaGpu->SetCudaDeviceID(i);
                CudaGpu->ReadGPUSettings();
                GetHardProfile()->AddGPU(CudaGpu);
                if(i==0)
                {//?? set first one as main...??
                        GetHardProfile()->SetMainGPU(CudaGpu);
                        GetHardProfile()->SetRenderingGPU(CudaGpu);
                        GetHardProfile()->SetProcessingGPU(CudaGpu);
                }
                //what about the already detected GPU from GPU_NVIDIA??
        }	
        
#if _DEBUG
        gcudaPrintProperties();
        //MainGPU()->SetGLSLProfile(GenericGPU::HRD_PRF_0);
#endif
        return true;
}

//==================================================
void cvgCudaThreadSynchronize()
{
        gcudaThreadSynchronize();
}
#endif//CUDA_SUPPORT

Powered by WebSVN v1.61