Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -20,13 +20,11 @@ subject to the following restrictions:
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
cl_context g_cxMainContext;
|
||||
cl_command_queue g_cqCommandQue;
|
||||
|
||||
cl_context g_cxMainContext;
|
||||
cl_command_queue g_cqCommandQue;
|
||||
|
||||
#include "Bullet3Common/b3Logging.h"
|
||||
|
||||
|
||||
void myerrorwarningprintf(const char* msg)
|
||||
{
|
||||
//OutputDebugStringA(msg);
|
||||
@@ -54,64 +52,63 @@ int main(int argc, char* argv[])
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_ALL;
|
||||
const char* vendorSDK = b3OpenCLUtils::getSdkVendorName();
|
||||
|
||||
b3Printf("This program was compiled using the %s OpenCL SDK\n",vendorSDK);
|
||||
b3Printf("This program was compiled using the %s OpenCL SDK\n", vendorSDK);
|
||||
int numPlatforms = b3OpenCLUtils::getNumPlatforms();
|
||||
b3Printf("Num Platforms = %d\n", numPlatforms);
|
||||
|
||||
for (int i=0;i<numPlatforms;i++)
|
||||
for (int i = 0; i < numPlatforms; i++)
|
||||
{
|
||||
cl_platform_id platform = b3OpenCLUtils::getPlatform(i);
|
||||
b3OpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLUtils::getPlatformInfo(platform,&platformInfo);
|
||||
b3OpenCLUtils::getPlatformInfo(platform, &platformInfo);
|
||||
b3Printf("--------------------------------\n");
|
||||
b3Printf("Platform info for platform nr %d:\n",i);
|
||||
b3Printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor);
|
||||
b3Printf(" CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName);
|
||||
b3Printf(" CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion);
|
||||
b3Printf("Platform info for platform nr %d:\n", i);
|
||||
b3Printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n", platformInfo.m_platformVendor);
|
||||
b3Printf(" CL_PLATFORM_NAME: \t\t\t%s\n", platformInfo.m_platformName);
|
||||
b3Printf(" CL_PLATFORM_VERSION: \t\t\t%s\n", platformInfo.m_platformVersion);
|
||||
|
||||
g_cxMainContext = b3OpenCLUtils::createContextFromPlatform(platform,deviceType,&ciErrNum);
|
||||
g_cxMainContext = b3OpenCLUtils::createContextFromPlatform(platform, deviceType, &ciErrNum);
|
||||
|
||||
int numDevices = b3OpenCLUtils::getNumDevices(g_cxMainContext);
|
||||
b3Printf("Num Devices = %d\n", numDevices);
|
||||
for (int j=0;j<numDevices;j++)
|
||||
for (int j = 0; j < numDevices; j++)
|
||||
{
|
||||
cl_device_id device = b3OpenCLUtils::getDevice(g_cxMainContext,j);
|
||||
cl_device_id device = b3OpenCLUtils::getDevice(g_cxMainContext, j);
|
||||
b3OpenCLDeviceInfo devInfo;
|
||||
b3OpenCLUtils::getDeviceInfo(device,&devInfo);
|
||||
b3OpenCLUtils::getDeviceInfo(device, &devInfo);
|
||||
b3OpenCLUtils::printDeviceInfo(device);
|
||||
g_cqCommandQue = clCreateCommandQueue(g_cxMainContext, device, 0, &ciErrNum);
|
||||
|
||||
b3OpenCLArray<char> memTester(g_cxMainContext,g_cqCommandQue,0,true);
|
||||
b3OpenCLArray<char> memTester(g_cxMainContext, g_cqCommandQue, 0, true);
|
||||
int maxMem = 0;
|
||||
bool result=true;
|
||||
for (size_t i=1;result;i++)
|
||||
bool result = true;
|
||||
for (size_t i = 1; result; i++)
|
||||
{
|
||||
size_t numBytes = i*1024*1024;
|
||||
result = memTester.resize(numBytes,false);
|
||||
size_t numBytes = i * 1024 * 1024;
|
||||
result = memTester.resize(numBytes, false);
|
||||
|
||||
if (result)
|
||||
{
|
||||
maxMem = numBytes;
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("allocated %d MB successfully\n",maxMem/(1024*1024));
|
||||
printf("allocated %d MB successfully\n", maxMem / (1024 * 1024));
|
||||
clReleaseCommandQueue(g_cqCommandQue);
|
||||
g_cqCommandQue=0;
|
||||
|
||||
g_cqCommandQue = 0;
|
||||
}
|
||||
|
||||
clReleaseContext(g_cxMainContext);
|
||||
g_cxMainContext=0;
|
||||
g_cxMainContext = 0;
|
||||
}
|
||||
|
||||
///Easier method to initialize OpenCL using createContextFromType for a GPU
|
||||
deviceType = CL_DEVICE_TYPE_GPU;
|
||||
|
||||
void* glCtx=0;
|
||||
void* glCtx = 0;
|
||||
void* glDC = 0;
|
||||
b3Printf("Initialize OpenCL using b3OpenCLUtils::createContextFromType for CL_DEVICE_TYPE_GPU\n");
|
||||
g_cxMainContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
|
||||
@@ -121,48 +118,47 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
int numDev = b3OpenCLUtils::getNumDevices(g_cxMainContext);
|
||||
|
||||
for (int i=0;i<numDev;i++)
|
||||
for (int i = 0; i < numDev; i++)
|
||||
{
|
||||
cl_device_id device;
|
||||
device = b3OpenCLUtils::getDevice(g_cxMainContext,i);
|
||||
cl_device_id device;
|
||||
device = b3OpenCLUtils::getDevice(g_cxMainContext, i);
|
||||
b3OpenCLDeviceInfo clInfo;
|
||||
b3OpenCLUtils::getDeviceInfo(device,&clInfo);
|
||||
b3OpenCLUtils::getDeviceInfo(device, &clInfo);
|
||||
b3OpenCLUtils::printDeviceInfo(device);
|
||||
// create a command-queue
|
||||
g_cqCommandQue = clCreateCommandQueue(g_cxMainContext, device, 0, &ciErrNum);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
//normally you would create and execute kernels using this command queue
|
||||
|
||||
int maxMem = 0;
|
||||
|
||||
int maxMem = 0;
|
||||
{
|
||||
b3OpenCLArray<char> memTester(g_cxMainContext,g_cqCommandQue,0,true);
|
||||
|
||||
bool result=true;
|
||||
for (size_t i=1;result;i++)
|
||||
{
|
||||
size_t numBytes = i*1024*1024;
|
||||
result = memTester.resize(numBytes,false);
|
||||
b3OpenCLArray<char> memTester(g_cxMainContext, g_cqCommandQue, 0, true);
|
||||
|
||||
if (result)
|
||||
{
|
||||
maxMem=numBytes;
|
||||
|
||||
} else
|
||||
{
|
||||
bool result = true;
|
||||
for (size_t i = 1; result; i++)
|
||||
{
|
||||
size_t numBytes = i * 1024 * 1024;
|
||||
result = memTester.resize(numBytes, false);
|
||||
|
||||
if (result)
|
||||
{
|
||||
maxMem = numBytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("allocated %d MB successfully\n",maxMem/(1024*1024));
|
||||
}
|
||||
}
|
||||
printf("allocated %d MB successfully\n", maxMem / (1024 * 1024));
|
||||
}
|
||||
|
||||
|
||||
clReleaseCommandQueue(g_cqCommandQue);
|
||||
}
|
||||
|
||||
clReleaseContext(g_cxMainContext);
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
b3Printf("No OpenCL capable GPU found!");
|
||||
}
|
||||
b3Printf("press <Enter>\n");
|
||||
|
||||
Reference in New Issue
Block a user