improve the benchmark mode, with 2 files (csv and details)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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=<int>] [--cl_device=<int>] [--benchmark] [--disable_opencl] [--cl_platform=<int>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>] [--use_concave_mesh] [--new_batching]\n");
|
||||
printf("\nprogram.exe [--selected_demo=<int>] [--cl_device=<int>] [--benchmark] [--dump_timings] [--disable_opencl] [--cl_platform=<int>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>] [--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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user