Build fixes for GPU samples.

This commit is contained in:
Alexander Smorkalov 2015-01-13 13:22:41 +03:00
parent c0d76ef984
commit b0c5f49170
3 changed files with 6 additions and 7 deletions

8
samples/gpu/driver_api_multi.cpp Executable file → Normal file
View File

@ -41,8 +41,8 @@ struct Worker: public ParallelLoopBody
Worker(int num_devices)
{
count = num_devices;
contexts = new contexts CUcontext[num_devices];
for (int device_id = 0; i < num_devices; device_id++)
contexts = new CUcontext[num_devices];
for (int device_id = 0; device_id < num_devices; device_id++)
{
CUdevice device;
safeCall(cuDeviceGet(&device, device_id));
@ -90,7 +90,7 @@ struct Worker: public ParallelLoopBody
{
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]));
}
@ -130,7 +130,7 @@ int main()
safeCall(cuInit(0));
// Execute calculation
parallel_for_(cv::Range(0, num_devices, Worker(num_devices));
parallel_for_(cv::Range(0, num_devices), Worker(num_devices));
return 0;
}

View File

@ -8,7 +8,6 @@
#endif
#include <iostream>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
@ -169,7 +168,7 @@ int main(int argc, char** argv)
contextOff();
// 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
contextOn(0);

View File

@ -72,7 +72,7 @@ int main()
}
// 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;
}