Build fixes for GPU samples.
This commit is contained in:
8
samples/gpu/driver_api_multi.cpp
Executable file → Normal file
8
samples/gpu/driver_api_multi.cpp
Executable file → Normal file
@@ -41,8 +41,8 @@ struct Worker: public ParallelLoopBody
|
|||||||
Worker(int num_devices)
|
Worker(int num_devices)
|
||||||
{
|
{
|
||||||
count = num_devices;
|
count = num_devices;
|
||||||
contexts = new contexts CUcontext[num_devices];
|
contexts = new CUcontext[num_devices];
|
||||||
for (int device_id = 0; i < num_devices; device_id++)
|
for (int device_id = 0; device_id < num_devices; device_id++)
|
||||||
{
|
{
|
||||||
CUdevice device;
|
CUdevice device;
|
||||||
safeCall(cuDeviceGet(&device, device_id));
|
safeCall(cuDeviceGet(&device, device_id));
|
||||||
@@ -90,7 +90,7 @@ struct Worker: public ParallelLoopBody
|
|||||||
{
|
{
|
||||||
if ((contexts != NULL) && count != 0)
|
if ((contexts != NULL) && count != 0)
|
||||||
{
|
{
|
||||||
for (int device_id = 0; i < num_devices; device_id++)
|
for (int device_id = 0; device_id < count; device_id++)
|
||||||
{
|
{
|
||||||
safeCall(cuCtxDestroy(contexts[device_id]));
|
safeCall(cuCtxDestroy(contexts[device_id]));
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ int main()
|
|||||||
safeCall(cuInit(0));
|
safeCall(cuInit(0));
|
||||||
|
|
||||||
// Execute calculation
|
// Execute calculation
|
||||||
parallel_for_(cv::Range(0, num_devices, Worker(num_devices));
|
parallel_for_(cv::Range(0, num_devices), Worker(num_devices));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "cvconfig.h"
|
|
||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
#include "opencv2/gpu/gpu.hpp"
|
#include "opencv2/gpu/gpu.hpp"
|
||||||
@@ -169,7 +168,7 @@ int main(int argc, char** argv)
|
|||||||
contextOff();
|
contextOff();
|
||||||
|
|
||||||
// Execute calculation in two threads using two GPUs
|
// Execute calculation in two threads using two GPUs
|
||||||
parallel_for_(cv::Range(0, 2, Worker());
|
parallel_for_(cv::Range(0, 2), Worker());
|
||||||
|
|
||||||
// Release the first GPU resources
|
// Release the first GPU resources
|
||||||
contextOn(0);
|
contextOn(0);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute calculation in several threads, 1 GPU per thread
|
// Execute calculation in several threads, 1 GPU per thread
|
||||||
parallel_for_(cv::Range(0, num_devices, Worker());
|
parallel_for_(cv::Range(0, num_devices), Worker());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user