From 084bc4ec32d53036d4e4d1f5a27344fcf075bac4 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 23 May 2013 18:34:39 -0700 Subject: [PATCH] improve the benchmark mode, with 2 files (csv and details) --- Demos3/GpuDemos/GpuDemo.cpp | 11 ++- Demos3/GpuDemos/GpuDemo.h | 8 +- Demos3/GpuDemos/GpuDemoInternalData.h | 1 + Demos3/GpuDemos/main_opengl3core.cpp | 98 ++++++++++++++----- Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp | 2 +- src/Bullet3Common/b3Quickprof.cpp | 62 ++++++++++++ src/Bullet3Common/b3Quickprof.h | 4 +- .../Initialize/b3OpenCLUtils.cpp | 84 ++++++++-------- src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h | 19 +++- test/OpenCL/RadixSortBenchmark/main.cpp | 2 +- 10 files changed, 209 insertions(+), 82 deletions(-) diff --git a/Demos3/GpuDemos/GpuDemo.cpp b/Demos3/GpuDemos/GpuDemo.cpp index 00a035130..d1c626d6b 100644 --- a/Demos3/GpuDemos/GpuDemo.cpp +++ b/Demos3/GpuDemos/GpuDemo.cpp @@ -46,15 +46,14 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex) cl_device_type deviceType = CL_DEVICE_TYPE_GPU; //#endif - cl_platform_id platformId; + // if (useInterop) // { // m_data->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, glCtx, glDC); // } else { - m_clData->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, 0,0,preferredDeviceIndex, preferredPlatformIndex,&platformId); - b3OpenCLUtils::printPlatformInfo(platformId); + m_clData->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, 0,0,preferredDeviceIndex, preferredPlatformIndex,&m_clData->m_platformId); } @@ -68,7 +67,7 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex) m_clData->m_clQueue = clCreateCommandQueue(m_clData->m_clContext, m_clData->m_clDevice, 0, &ciErrNum); oclCHECKERROR(ciErrNum, CL_SUCCESS); - b3OpenCLUtils::printDeviceInfo(m_clData->m_clDevice); + b3OpenCLDeviceInfo info; b3OpenCLUtils::getDeviceInfo(m_clData->m_clDevice,&info); m_clData->m_clDeviceName = info.m_deviceName; @@ -78,6 +77,10 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex) } +GpuDemoInternalData* GpuDemo::getInternalData() +{ + return m_clData; +} int GpuDemo::registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites, int largeSphereThreshold, int mediumSphereThreshold) { diff --git a/Demos3/GpuDemos/GpuDemo.h b/Demos3/GpuDemos/GpuDemo.h index 4d972e916..84a283abb 100644 --- a/Demos3/GpuDemos/GpuDemo.h +++ b/Demos3/GpuDemos/GpuDemo.h @@ -38,9 +38,9 @@ public: :useOpenCL(true), preferredOpenCLPlatformIndex(-1), preferredOpenCLDeviceIndex(-1), - arraySizeX(25), - arraySizeY(20), - arraySizeZ(25), + arraySizeX(30), + arraySizeY(30), + arraySizeZ(30), m_useConcaveMesh(false), gapX(14.3), gapY(14.0), @@ -67,6 +67,8 @@ public: int registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites=true, int largeSphereThreshold=100, int mediumSphereThreshold=10); + struct GpuDemoInternalData* getInternalData(); + }; #endif diff --git a/Demos3/GpuDemos/GpuDemoInternalData.h b/Demos3/GpuDemos/GpuDemoInternalData.h index b4460e3c6..437cb82ed 100644 --- a/Demos3/GpuDemos/GpuDemoInternalData.h +++ b/Demos3/GpuDemos/GpuDemoInternalData.h @@ -5,6 +5,7 @@ struct GpuDemoInternalData { + cl_platform_id m_platformId; cl_context m_clContext; cl_device_id m_clDevice; cl_command_queue m_clQueue; diff --git a/Demos3/GpuDemos/main_opengl3core.cpp b/Demos3/GpuDemos/main_opengl3core.cpp index 03f28a5b6..ed2bbc8e1 100644 --- a/Demos3/GpuDemos/main_opengl3core.cpp +++ b/Demos3/GpuDemos/main_opengl3core.cpp @@ -13,6 +13,9 @@ #include "OpenGLWindow/X11OpenGLWindow.h" #endif +#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h" +#include "GpuDemoInternalData.h" + #include "OpenGLWindow/GLPrimitiveRenderer.h" #include "OpenGLWindow/GLInstancingRenderer.h" //#include "OpenGL3CoreRenderer.h" @@ -324,7 +327,7 @@ sth_stash* initFont(GLPrimitiveRenderer* primRender) void Usage() { - printf("\nprogram.exe [--selected_demo=] [--cl_device=] [--benchmark] [--disable_opencl] [--cl_platform=] [--x_dim=] [--y_dim=] [--z_dim=] [--x_gap=] [--y_gap=] [--z_gap=] [--use_concave_mesh] [--new_batching]\n"); + printf("\nprogram.exe [--selected_demo=] [--cl_device=] [--benchmark] [--dump_timings] [--disable_opencl] [--cl_platform=] [--x_dim=] [--y_dim=] [--z_dim=] [--x_gap=] [--y_gap=] [--z_gap=] [--use_concave_mesh] [--new_batching]\n"); }; @@ -394,6 +397,7 @@ extern bool useNewBatchingKernel; int main(int argc, char* argv[]) { + FILE* defaultOutput = stdout; b3Vector3 test(1,2,3); test.x = 1; @@ -437,13 +441,6 @@ int main(int argc, char* argv[]) args.GetCmdLineArgument("z_gap", ci.gapZ); - printf("Demo settings:\n"); - printf("x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ); - printf("x_gap=%f, y_gap=%f, z_gap=%f\n",ci.gapX,ci.gapY,ci.gapZ); - - printf("Preferred cl_device index %d\n", ci.preferredOpenCLDeviceIndex); - printf("Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex); - printf("-----------------------------------------------------\n"); #ifndef B3_NO_PROFILE b3ProfileManager::Reset(); @@ -606,13 +603,25 @@ int main(int argc, char* argv[]) // render.init(); demo->initPhysics(ci); + + + + + printf("-----------------------------------------------------\n"); - FILE* f = 0; + FILE* csvFile = 0; + FILE* detailsFile = 0; + if (benchmark) { gPause = false; - char fileName[1024]; + char prefixFileName[1024]; + char csvFileName[1024]; + char detailsFileName[1024]; + + b3OpenCLDeviceInfo info; + b3OpenCLUtils::getDeviceInfo(demo->getInternalData()->m_clDevice,&info); #ifdef _WIN32 SYSTEMTIME time; @@ -626,23 +635,43 @@ int main(int argc, char* argv[]) { printf("unknown", buf); } - sprintf(fileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d.csv",g_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond); - printf("Open file %s\n", fileName); + sprintf(prefixFileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d",info.m_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond); + #else - sprintf(fileName,"%s_%d_%d_%d.csv",g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ); - printf("Open file %s\n", fileName); + sprintf(prefixFileName,"%s_%d_%d_%d",info.m_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ); + #endif + sprintf(csvFileName,"%s.csv",prefixFileName); + sprintf(detailsFileName,"%s.txt",prefixFileName); + printf("Open csv file %s and details file %s\n", csvFileName,detailsFileName); //GetSystemTime(&time2); - f=fopen(fileName,"w"); + csvFile=fopen(csvFileName,"w"); + detailsFile = fopen(detailsFileName,"w"); + if (detailsFile) + defaultOutput = detailsFile; + //if (f) // fprintf(f,"%s (%dx%dx%d=%d),\n", g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,ci.arraySizeX*ci.arraySizeY*ci.arraySizeZ); } - printf("-----------------------------------------------------\n"); + + fprintf(defaultOutput,"Demo settings:\n"); + fprintf(defaultOutput," SelectedDemo=%d, demoname = %s\n", selectedDemo, demo->getName()); + fprintf(defaultOutput," x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ); + fprintf(defaultOutput," x_gap=%f, y_gap=%f, z_gap=%f\n",ci.gapX,ci.gapY,ci.gapZ); + fprintf(defaultOutput,"\nOpenCL settings:\n"); + fprintf(defaultOutput," Preferred cl_device index %d\n", ci.preferredOpenCLDeviceIndex); + fprintf(defaultOutput," Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex); + fprintf(defaultOutput,"\n"); + + b3OpenCLUtils::printPlatformInfo(defaultOutput, demo->getInternalData()->m_platformId); + fprintf(defaultOutput,"\n"); + b3OpenCLUtils::printDeviceInfo(defaultOutput, demo->getInternalData()->m_clDevice); + fprintf(defaultOutput,"\n"); do { b3ProfileManager::Reset(); @@ -697,21 +726,30 @@ int main(int argc, char* argv[]) B3_PROFILE("glFinish"); } + if (dump_timings) - b3ProfileManager::dumpAll(); - - if (f) { - static int count=0; + b3ProfileManager::dumpAll(stdout); + } - if (count>2 && count<102) + if (csvFile) + { + static int frameCount=0; + + if (frameCount>0) { - DumpSimulationTime(f); + DumpSimulationTime(csvFile); + if (detailsFile) + { + fprintf(detailsFile,"\n==================================\nFrame %d:\n", frameCount); + b3ProfileManager::dumpAll(detailsFile); + } } - if (count>=102) + + if (frameCount>=102) window->setRequestExit(); - count++; + frameCount++; } @@ -722,8 +760,16 @@ int main(int argc, char* argv[]) demo->exitPhysics(); b3ProfileManager::CleanupMemory(); delete demo; - if (f) - fclose(f); + if (detailsFile) + { + fclose(detailsFile); + detailsFile=0; + } + if (csvFile) + { + fclose(csvFile); + csvFile=0; + } } diff --git a/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp b/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp index a394952fd..82eda0ace 100644 --- a/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp +++ b/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp @@ -33,7 +33,7 @@ void GpuConvexScene::setupScene(const ConstructionInfo& ci) float camPos[4]={ci.arraySizeX,ci.arraySizeY/2,ci.arraySizeZ,0}; //float camPos[4]={1,12.5,1.5,0}; m_instancingRenderer->setCameraTargetPosition(camPos); - m_instancingRenderer->setCameraDistance(40); + m_instancingRenderer->setCameraDistance(100); char msg[1024]; diff --git a/src/Bullet3Common/b3Quickprof.cpp b/src/Bullet3Common/b3Quickprof.cpp index 12bda2fd3..fffca40eb 100644 --- a/src/Bullet3Common/b3Quickprof.cpp +++ b/src/Bullet3Common/b3Quickprof.cpp @@ -565,6 +565,7 @@ void b3ProfileManager::dumpRecursive(b3ProfileIterator* profileIterator, int spa + void b3ProfileManager::dumpAll() { b3ProfileIterator* profileIterator = 0; @@ -576,6 +577,67 @@ void b3ProfileManager::dumpAll() } +void b3ProfileManager::dumpRecursive(FILE* f, b3ProfileIterator* profileIterator, int spacing) +{ + profileIterator->First(); + if (profileIterator->Is_Done()) + return; + + float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); + int i; + int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset(); + for (i=0;iGet_Current_Parent_Name(), parent_time ); + float totalTime = 0.f; + + + int numChildren = 0; + + for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next()) + { + numChildren++; + float current_total_time = profileIterator->Get_Current_Total_Time(); + accumulated_time += current_total_time; + float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + { + int i; for (i=0;iGet_Current_Name(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->Get_Current_Total_Calls()); + totalTime += current_total_time; + //recurse into children + } + + if (parent_time < accumulated_time) + { + fprintf(f,"what's wrong\n"); + } + for (i=0;i B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); + + for (i=0;iEnter_Child(i); + dumpRecursive(f,profileIterator,spacing+3); + profileIterator->Enter_Parent(); + } +} + + + + +void b3ProfileManager::dumpAll(FILE* f) +{ + b3ProfileIterator* profileIterator = 0; + profileIterator = b3ProfileManager::Get_Iterator(); + + dumpRecursive(f, profileIterator,0); + + b3ProfileManager::Release_Iterator(profileIterator); +} + #endif //B3_NO_PROFILE diff --git a/src/Bullet3Common/b3Quickprof.h b/src/Bullet3Common/b3Quickprof.h index f70300626..62d0d1f71 100644 --- a/src/Bullet3Common/b3Quickprof.h +++ b/src/Bullet3Common/b3Quickprof.h @@ -174,9 +174,11 @@ public: static void Release_Iterator( b3ProfileIterator * iterator ) { delete ( iterator); } static void dumpRecursive(b3ProfileIterator* profileIterator, int spacing); - static void dumpAll(); + static void dumpRecursive(FILE* f, b3ProfileIterator* profileIterator, int spacing); + static void dumpAll(FILE* f); + private: static b3ProfileNode Root; static b3ProfileNode * CurrentNode; diff --git a/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp b/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp index 02e50e3ff..eccbed6f6 100644 --- a/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp +++ b/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp @@ -188,14 +188,14 @@ void b3OpenCLUtils::getPlatformInfo(cl_platform_id platform, b3OpenCLPlatformInf oclCHECKERROR(ciErrNum,CL_SUCCESS); } -void b3OpenCLUtils_printPlatformInfo(cl_platform_id platform) +void b3OpenCLUtils_printPlatformInfo(FILE* f, cl_platform_id platform) { b3OpenCLPlatformInfo platformInfo; b3OpenCLUtils::getPlatformInfo (platform, &platformInfo); - printf("Platform info:\n"); - printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor); - printf(" CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName); - printf(" CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion); + fprintf(f,"Platform info:\n"); + fprintf(f," CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor); + fprintf(f," CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName); + fprintf(f," CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion); } @@ -216,7 +216,7 @@ cl_context b3OpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_d cl_context_properties cps[7] = {0,0,0,0,0,0,0}; cps[0] = CL_CONTEXT_PLATFORM; cps[1] = (cl_context_properties)platform; -#ifdef _WIN32 && +#ifdef _WIN32 #ifndef B3_USE_CLEW if (pGLContext && pGLDC) { @@ -500,57 +500,57 @@ void b3OpenCLUtils::getDeviceInfo(cl_device_id device, b3OpenCLDeviceInfo* info) } -void b3OpenCLUtils_printDeviceInfo(cl_device_id device) +void b3OpenCLUtils_printDeviceInfo(FILE* f, cl_device_id device) { b3OpenCLDeviceInfo info; b3OpenCLUtils::getDeviceInfo(device,&info); - printf("Device Info:\n"); - printf(" CL_DEVICE_NAME: \t\t\t%s\n", info.m_deviceName); - printf(" CL_DEVICE_VENDOR: \t\t\t%s\n", info.m_deviceVendor); - printf(" CL_DRIVER_VERSION: \t\t\t%s\n", info.m_driverVersion); + fprintf(f,"Device Info:\n"); + fprintf(f," CL_DEVICE_NAME: \t\t\t%s\n", info.m_deviceName); + fprintf(f," CL_DEVICE_VENDOR: \t\t\t%s\n", info.m_deviceVendor); + fprintf(f," CL_DRIVER_VERSION: \t\t\t%s\n", info.m_driverVersion); if( info.m_deviceType & CL_DEVICE_TYPE_CPU ) - printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU"); + fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU"); if( info.m_deviceType & CL_DEVICE_TYPE_GPU ) - printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU"); + fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU"); if( info.m_deviceType & CL_DEVICE_TYPE_ACCELERATOR ) - printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR"); + fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR"); if( info.m_deviceType & CL_DEVICE_TYPE_DEFAULT ) - printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT"); + fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT"); - printf(" CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", info.m_computeUnits); - printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", info.m_workitemDims); - printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", info.m_workItemSize[0], info.m_workItemSize[1], info.m_workItemSize[2]); - printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", info.m_workgroupSize); - printf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", info.m_clockFrequency); - printf(" CL_DEVICE_ADDRESS_BITS:\t\t%u\n", info.m_addressBits); - printf(" CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_maxMemAllocSize/ (1024 * 1024))); - printf(" CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_globalMemSize/ (1024 * 1024))); - printf(" CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", info.m_errorCorrectionSupport== CL_TRUE ? "yes" : "no"); - printf(" CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", info.m_localMemType == 1 ? "local" : "global"); - printf(" CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(info.m_localMemSize / 1024)); - printf(" CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(info.m_constantBufferSize / 1024)); + fprintf(f," CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", info.m_computeUnits); + fprintf(f," CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", info.m_workitemDims); + fprintf(f," CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", info.m_workItemSize[0], info.m_workItemSize[1], info.m_workItemSize[2]); + fprintf(f," CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", info.m_workgroupSize); + fprintf(f," CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", info.m_clockFrequency); + fprintf(f," CL_DEVICE_ADDRESS_BITS:\t\t%u\n", info.m_addressBits); + fprintf(f," CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_maxMemAllocSize/ (1024 * 1024))); + fprintf(f," CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_globalMemSize/ (1024 * 1024))); + fprintf(f," CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", info.m_errorCorrectionSupport== CL_TRUE ? "yes" : "no"); + fprintf(f," CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", info.m_localMemType == 1 ? "local" : "global"); + fprintf(f," CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(info.m_localMemSize / 1024)); + fprintf(f," CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(info.m_constantBufferSize / 1024)); if( info.m_queueProperties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) - printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE"); + fprintf(f," CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE"); if( info.m_queueProperties & CL_QUEUE_PROFILING_ENABLE ) - printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE"); + fprintf(f," CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE"); - printf(" CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", info.m_imageSupport); + fprintf(f," CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", info.m_imageSupport); - printf(" CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", info.m_maxReadImageArgs); - printf(" CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", info.m_maxWriteImageArgs); - printf("\n CL_DEVICE_IMAGE "); - printf("\t\t\t2D_MAX_WIDTH\t %u\n", info.m_image2dMaxWidth); - printf("\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", info.m_image2dMaxHeight); - printf("\t\t\t\t\t3D_MAX_WIDTH\t %u\n", info.m_image3dMaxWidth); - printf("\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", info.m_image3dMaxHeight); - printf("\t\t\t\t\t3D_MAX_DEPTH\t %u\n", info.m_image3dMaxDepth); + fprintf(f," CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", info.m_maxReadImageArgs); + fprintf(f," CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", info.m_maxWriteImageArgs); + fprintf(f,"\n CL_DEVICE_IMAGE "); + fprintf(f,"\t\t\t2D_MAX_WIDTH\t %u\n", info.m_image2dMaxWidth); + fprintf(f,"\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", info.m_image2dMaxHeight); + fprintf(f,"\t\t\t\t\t3D_MAX_WIDTH\t %u\n", info.m_image3dMaxWidth); + fprintf(f,"\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", info.m_image3dMaxHeight); + fprintf(f,"\t\t\t\t\t3D_MAX_DEPTH\t %u\n", info.m_image3dMaxDepth); if (info.m_deviceExtensions != 0) - printf("\n CL_DEVICE_EXTENSIONS:%s\n",info.m_deviceExtensions); + fprintf(f,"\n CL_DEVICE_EXTENSIONS:%s\n",info.m_deviceExtensions); else - printf(" CL_DEVICE_EXTENSIONS: None\n"); - printf(" CL_DEVICE_PREFERRED_VECTOR_WIDTH_\t"); - printf("CHAR %u, SHORT %u, INT %u,LONG %u, FLOAT %u, DOUBLE %u\n\n\n", + fprintf(f," CL_DEVICE_EXTENSIONS: None\n"); + fprintf(f," CL_DEVICE_PREFERRED_VECTOR_WIDTH_\t"); + fprintf(f,"CHAR %u, SHORT %u, INT %u,LONG %u, FLOAT %u, DOUBLE %u\n\n\n", info.m_vecWidthChar, info.m_vecWidthShort, info.m_vecWidthInt, info.m_vecWidthLong,info.m_vecWidthFloat, info.m_vecWidthDouble); diff --git a/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h b/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h index d7af1ab01..7f0e08949 100644 --- a/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h +++ b/src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h @@ -36,7 +36,7 @@ int b3OpenCLUtils_getNumDevices(cl_context cxMainContext); cl_device_id b3OpenCLUtils_getDevice(cl_context cxMainContext, int nr); -void b3OpenCLUtils_printDeviceInfo(cl_device_id device); +void b3OpenCLUtils_printDeviceInfo(FILE* f, cl_device_id device); cl_kernel b3OpenCLUtils_compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum, cl_program prog,const char* additionalMacros); @@ -49,7 +49,8 @@ int b3OpenCLUtils_getNumPlatforms(cl_int* pErrNum); ///get the nr'th platform, where nr is in the range [0..getNumPlatforms) cl_platform_id b3OpenCLUtils_getPlatform(int nr, cl_int* pErrNum); -void b3OpenCLUtils_printPlatformInfo(cl_platform_id platform); + +void b3OpenCLUtils_printPlatformInfo(FILE* f, cl_platform_id platform); const char* b3OpenCLUtils_getSdkVendorName(); @@ -132,7 +133,12 @@ struct b3OpenCLUtils static inline void printDeviceInfo(cl_device_id device) { - b3OpenCLUtils_printDeviceInfo(device); + b3OpenCLUtils_printDeviceInfo(stdout, device); + } + + static inline void printDeviceInfo(FILE* f, cl_device_id device) + { + b3OpenCLUtils_printDeviceInfo(f,device); } static inline cl_kernel compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum=0, cl_program prog=0,const char* additionalMacros = "" ) @@ -161,7 +167,12 @@ struct b3OpenCLUtils static inline void printPlatformInfo(cl_platform_id platform) { - b3OpenCLUtils_printPlatformInfo(platform); + b3OpenCLUtils_printPlatformInfo(stdout, platform); + } + + static inline void printPlatformInfo(FILE* f, cl_platform_id platform) + { + b3OpenCLUtils_printPlatformInfo(f,platform); } static inline const char* getSdkVendorName() diff --git a/test/OpenCL/RadixSortBenchmark/main.cpp b/test/OpenCL/RadixSortBenchmark/main.cpp index 207f28f0c..437f83dbd 100644 --- a/test/OpenCL/RadixSortBenchmark/main.cpp +++ b/test/OpenCL/RadixSortBenchmark/main.cpp @@ -667,7 +667,7 @@ int main( int argc, char** argv) int result; int devId = 0; g_device = b3OpenCLUtils_getDevice(g_cxMainContext,devId); - b3OpenCLUtils_printDeviceInfo(g_device); + b3OpenCLUtils_printDeviceInfo(stdout, g_device); // create a command-queue g_cqCommandQueue = clCreateCommandQueue(g_cxMainContext, g_device, 0, &ciErrNum); oclCHECKERROR(ciErrNum, CL_SUCCESS);