Revision: 1510
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1510&view=rev
Author: rorthomas
Date: 2010-08-08 20:32:30 +0000 (Sun, 08 Aug 2010)
Log Message:
-----------
no crash upon openCL error
Modified Paths:
--------------
trunk/source/configurator/configurator.cpp
trunk/source/configurator/ocl_bwtest.h
Modified: trunk/source/configurator/configurator.cpp
===================================================================
--- trunk/source/configurator/configurator.cpp 2010-08-08 19:54:46 UTC (rev
1509)
+++ trunk/source/configurator/configurator.cpp 2010-08-08 20:32:30 UTC (rev
1510)
@@ -3424,90 +3424,97 @@
char cBuffer[1024];
cl_platform_id clSelectedPlatformID = NULL;
cl_int ciErrNum = oclGetPlatformID (&clSelectedPlatformID);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ if(ciErrNum != CL_SUCCESS)
+ {
+ tstream << "error getting platform info" << endl;
+ bPassed = false;
+ }
- // Get OpenCL platform name and version
- ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_NAME,
sizeof(cBuffer), cBuffer, NULL);
- if (ciErrNum == CL_SUCCESS)
- {
- tstream << "Platform Name: " << cBuffer << endl;
- }
- else
- {
- tstream << "Platform Name: ERROR " << ciErrNum << endl;
- bPassed = false;
- }
-
- ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_VERSION,
sizeof(cBuffer), cBuffer, NULL);
- if (ciErrNum == CL_SUCCESS)
- {
- tstream << "Platform Version: " << cBuffer << endl;
- }
- else
- {
- tstream << "Platform Version: ERROR " << ciErrNum << endl;
- bPassed = false;
- }
- tstream.flush();
+ if(bPassed)
+ {
+ // Get OpenCL platform name and version
+ ciErrNum = clGetPlatformInfo (clSelectedPlatformID,
CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL);
+ if (ciErrNum == CL_SUCCESS)
+ {
+ tstream << "Platform Name: " << cBuffer << endl;
+ }
+ else
+ {
+ tstream << "Platform Name: ERROR " << ciErrNum << endl;
+ bPassed = false;
+ }
+
+ ciErrNum = clGetPlatformInfo (clSelectedPlatformID,
CL_PLATFORM_VERSION, sizeof(cBuffer), cBuffer, NULL);
+ if (ciErrNum == CL_SUCCESS)
+ {
+ tstream << "Platform Version: " << cBuffer << endl;
+ }
+ else
+ {
+ tstream << "Platform Version: ERROR " << ciErrNum <<
endl;
+ bPassed = false;
+ }
+ tstream.flush();
- // Log OpenCL SDK Revision #
- tstream << "OpenCL SDK Revision: " << OCL_SDKREVISION << endl;
+ // Log OpenCL SDK Revision #
+ tstream << "OpenCL SDK Revision: " << OCL_SDKREVISION << endl;
- // Get and log OpenCL device info
- cl_uint ciDeviceCount;
- cl_device_id *devices;
- ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, 0,
NULL, &ciDeviceCount);
+ // Get and log OpenCL device info
+ cl_uint ciDeviceCount;
+ cl_device_id *devices;
+ ciErrNum = clGetDeviceIDs (clSelectedPlatformID,
CL_DEVICE_TYPE_ALL, 0, NULL, &ciDeviceCount);
- tstream << endl;
+ tstream << endl;
- tstream << "OpenCL Hardware Information:" << endl;
- tstream << "Devices found: " << ciDeviceCount << endl;
+ tstream << "OpenCL Hardware Information:" << endl;
+ tstream << "Devices found: " << ciDeviceCount << endl;
- // check for 0 devices found or errors...
- if (ciDeviceCount == 0)
- {
- tstream << "No devices found supporting OpenCL (return code "
<< ciErrNum << ")" << endl;
- bPassed = false;
- }
- else if (ciErrNum != CL_SUCCESS)
- {
- tstream << "Error in clGetDeviceIDs call: " << ciErrNum << endl;
- bPassed = false;
- }
- else
- {
- if ((devices = (cl_device_id*)malloc(sizeof(cl_device_id) *
ciDeviceCount)) == NULL)
+ // check for 0 devices found or errors...
+ if (ciDeviceCount == 0)
{
- tstream << "ERROR: Failed to allocate memory for
devices" << endl;
+ tstream << "No devices found supporting OpenCL (return
code " << ciErrNum << ")" << endl;
bPassed = false;
+ }
+ else if (ciErrNum != CL_SUCCESS)
+ {
+ tstream << "Error in clGetDeviceIDs call: " << ciErrNum
<< endl;
+ bPassed = false;
}
- ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL,
ciDeviceCount, devices, &ciDeviceCount);
- if (ciErrNum == CL_SUCCESS)
- {
- //Create a context for the devices
- cl_context cxGPUContext = clCreateContext(0, ciDeviceCount,
devices, NULL, NULL, &ciErrNum);
- if (ciErrNum != CL_SUCCESS)
- {
- tstream << "ERROR in clCreateContext call: " <<
ciErrNum << endl;
- bPassed = false;
- }
- else
- {
- // show info for each device in the context
- for(unsigned int i = 0; i < ciDeviceCount; ++i )
- {
- clGetDeviceInfo(devices[i], CL_DEVICE_NAME,
sizeof(cBuffer), &cBuffer, NULL);
- tstream << (i + 1) << " : Device " <<
cBuffer << endl;
- //oclPrintDevInfo(LOGBOTH, devices[i]);
- }
- }
- }
- else
- {
- tstream << "ERROR in clGetDeviceIDs call: " << ciErrNum
<< endl;
- bPassed = false;
- }
- }
+ else
+ {
+ if ((devices =
(cl_device_id*)malloc(sizeof(cl_device_id) * ciDeviceCount)) == NULL)
+ {
+ tstream << "ERROR: Failed to allocate memory
for devices" << endl;
+ bPassed = false;
+ }
+ ciErrNum = clGetDeviceIDs (clSelectedPlatformID,
CL_DEVICE_TYPE_ALL, ciDeviceCount, devices, &ciDeviceCount);
+ if (ciErrNum == CL_SUCCESS)
+ {
+ //Create a context for the devices
+ cl_context cxGPUContext = clCreateContext(0,
ciDeviceCount, devices, NULL, NULL, &ciErrNum);
+ if (ciErrNum != CL_SUCCESS)
+ {
+ tstream << "ERROR in clCreateContext
call: " << ciErrNum << endl;
+ bPassed = false;
+ }
+ else
+ {
+ // show info for each device in the
context
+ for(unsigned int i = 0; i <
ciDeviceCount; ++i )
+ {
+ clGetDeviceInfo(devices[i],
CL_DEVICE_NAME, sizeof(cBuffer), &cBuffer, NULL);
+ tstream << (i + 1) << " :
Device " << cBuffer << endl;
+ //oclPrintDevInfo(LOGBOTH,
devices[i]);
+ }
+ }
+ }
+ else
+ {
+ tstream << "ERROR in clGetDeviceIDs call: " <<
ciErrNum << endl;
+ bPassed = false;
+ }
+ }
+ }
// finish
if(bPassed)
tstream << "=== PASSED, OpenCL working ===" << endl;
Modified: trunk/source/configurator/ocl_bwtest.h
===================================================================
--- trunk/source/configurator/ocl_bwtest.h 2010-08-08 19:54:46 UTC (rev
1509)
+++ trunk/source/configurator/ocl_bwtest.h 2010-08-08 20:32:30 UTC (rev
1510)
@@ -80,6 +80,8 @@
double testHostToDeviceTransfer(unsigned int memSize, accessMode
accMode, memoryMode memMode);
double testDeviceToDeviceTransfer(unsigned int memSize);
void printResultsReadable(unsigned int *memSizes, double* bandwidths,
unsigned int count, memcpyKind kind, accessMode accMode, memoryMode memMode,
int iNumDevs);
+
+ void ownCheckError(int sample, int ref);
};
// class implementation
@@ -104,9 +106,12 @@
{
}
-///////////////////////////////////////////////////////////////////////////////
-//Parse args, run the appropriate tests
-///////////////////////////////////////////////////////////////////////////////
+void OpenCLTestBandwidth::ownCheckError(int sample, int ref)
+{
+ if(sample != ref)
+ stream << " ERROR " << endl;
+}
+
int OpenCLTestBandwidth::runTest(memoryMode memMode, accessMode accMode,
testMode mode)
{
int start = DEFAULT_SIZE;
@@ -121,7 +126,7 @@
// Get OpenCL platform ID for NVIDIA if available, otherwise default
cl_platform_id clSelectedPlatformID = NULL;
cl_int ciErrNum = oclGetPlatformID (&clSelectedPlatformID);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// Find out how many devices there are
cl_uint ciDeviceCount;
@@ -395,11 +400,11 @@
{
// Create a host buffer
cmPinnedData = clCreateBuffer(cxGPUContext, CL_MEM_READ_WRITE |
CL_MEM_ALLOC_HOST_PTR, memSize, NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// Get a mapped pointer
h_data = (unsigned char*)clEnqueueMapBuffer(cqCommandQueue,
cmPinnedData, CL_TRUE, CL_MAP_WRITE, 0, memSize, 0, NULL, NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
//initialize
for(unsigned int i = 0; i < memSize/sizeof(unsigned char); i++)
@@ -409,7 +414,7 @@
// unmap and make data in the host buffer valid
ciErrNum = clEnqueueUnmapMemObject(cqCommandQueue, cmPinnedData,
(void*)h_data, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
else
{
@@ -425,7 +430,7 @@
// allocate device memory
cmDevData = clCreateBuffer(cxGPUContext, CL_MEM_READ_WRITE, memSize, NULL,
&ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// initialize device memory
if(memMode == PINNED)
@@ -434,14 +439,14 @@
h_data = (unsigned char*)clEnqueueMapBuffer(cqCommandQueue,
cmPinnedData, CL_TRUE, CL_MAP_WRITE, 0, memSize, 0, NULL, NULL, &ciErrNum);
ciErrNum = clEnqueueWriteBuffer(cqCommandQueue, cmDevData, CL_FALSE,
0, memSize, h_data, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
else
{
ciErrNum = clEnqueueWriteBuffer(cqCommandQueue, cmDevData, CL_FALSE,
0, memSize, h_data, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// Sync queue to host, start timer 0, and copy data from GPU to Host
ciErrNum = clFinish(cqCommandQueue);
@@ -452,22 +457,22 @@
for(unsigned int i = 0; i < MEMCOPY_ITERATIONS; i++)
{
ciErrNum = clEnqueueReadBuffer(cqCommandQueue, cmDevData,
CL_FALSE, 0, memSize, h_data, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
ciErrNum = clFinish(cqCommandQueue);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
else
{
// MAPPED: mapped pointers to device buffer for conventional pointer
access
void* dm_idata = clEnqueueMapBuffer(cqCommandQueue, cmDevData,
CL_TRUE, CL_MAP_WRITE, 0, memSize, 0, NULL, NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
for(unsigned int i = 0; i < MEMCOPY_ITERATIONS; i++)
{
memcpy(h_data, dm_idata, memSize);
}
ciErrNum = clEnqueueUnmapMemObject(cqCommandQueue, cmDevData,
dm_idata, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
//get the the elapsed time in seconds
@@ -505,11 +510,11 @@
{
// Create a host buffer
cmPinnedData = clCreateBuffer(cxGPUContext, CL_MEM_READ_WRITE |
CL_MEM_ALLOC_HOST_PTR, memSize, NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// Get a mapped pointer
h_data = (unsigned char*)clEnqueueMapBuffer(cqCommandQueue,
cmPinnedData, CL_TRUE, CL_MAP_WRITE, 0, memSize, 0, NULL, NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
//initialize
for(unsigned int i = 0; i < memSize/sizeof(unsigned char); i++)
@@ -519,7 +524,7 @@
// unmap and make data in the host buffer valid
ciErrNum = clEnqueueUnmapMemObject(cqCommandQueue, cmPinnedData,
(void*)h_data, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
else
{
@@ -535,7 +540,7 @@
// allocate device memory
cmDevData = clCreateBuffer(cxGPUContext, CL_MEM_READ_WRITE, memSize, NULL,
&ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// Sync queue to host, start timer 0, and copy data from Host to GPU
clFinish(cqCommandQueue);
@@ -546,17 +551,17 @@
{
// Get a mapped pointer
h_data = (unsigned char*)clEnqueueMapBuffer(cqCommandQueue,
cmPinnedData, CL_TRUE, CL_MAP_WRITE, 0, memSize, 0, NULL, NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
// DIRECT: API access to device buffer
for(unsigned int i = 0; i < MEMCOPY_ITERATIONS; i++)
{
ciErrNum = clEnqueueWriteBuffer(cqCommandQueue, cmDevData,
CL_FALSE, 0, memSize, h_data, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
ciErrNum = clFinish(cqCommandQueue);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
else
{
@@ -567,7 +572,7 @@
memcpy(dm_idata, h_data, memSize);
}
ciErrNum = clEnqueueUnmapMemObject(cqCommandQueue, cmDevData,
dm_idata, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
//get the the elapsed time in seconds
@@ -609,11 +614,11 @@
// allocate device input and output memory and initialize the device input
memory
cl_mem d_idata = clCreateBuffer(cxGPUContext, CL_MEM_READ_ONLY, memSize,
NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
cl_mem d_odata = clCreateBuffer(cxGPUContext, CL_MEM_WRITE_ONLY, memSize,
NULL, &ciErrNum);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
ciErrNum = clEnqueueWriteBuffer(cqCommandQueue, d_idata, CL_TRUE, 0,
memSize, h_idata, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
// Sync queue to host, start timer 0, and copy data from one GPU buffer to
another GPU bufffer
clFinish(cqCommandQueue);
@@ -621,7 +626,7 @@
for(unsigned int i = 0; i < MEMCOPY_ITERATIONS; i++)
{
ciErrNum = clEnqueueCopyBuffer(cqCommandQueue, d_idata, d_odata, 0, 0,
memSize, 0, NULL, NULL);
- oclCheckError(ciErrNum, CL_SUCCESS);
+ ownCheckError(ciErrNum, CL_SUCCESS);
}
// Sync with GPU
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel