Commit f037992f authored by bbguimaraes's avatar bbguimaraes
Browse files

hcwocl: minor fixes

- use `const char*` for string literals
- do not use `NULL` as integer
- use `/` as path separator
- do not hard-code platforms
parent 96e043ae
......@@ -91,7 +91,7 @@ class KernelBuilder
{
public:
__inline
KernelBuilder( const DeviceDataBase* deviceData, char* fileName, const char* option = NULL, bool addExtension = false );
KernelBuilder( const DeviceDataBase* deviceData, const char* fileName, const char* option = NULL, bool addExtension = false );
__inline
void createKernel( const char* funcName, KERNEL& kernelOut );
......
......@@ -165,7 +165,8 @@ inline int DeviceUtilsCL::getNumDevices()
if( deviceType == CL_DEVICE_TYPE_GPU )
{
if( nvIdx != -1 ) platform = pIdx[nvIdx];
else platform = pIdx[atiIdx];
else if(atiIdx != -1) platform = pIdx[atiIdx];
else platform = pIdx[0];
}
else if( deviceType == CL_DEVICE_TYPE_CPU )
{
......@@ -220,7 +221,8 @@ inline void DeviceUtilsCL::initDevice( DeviceDataBase* deviceDataBase, DriverTyp
if( deviceType == CL_DEVICE_TYPE_GPU )
{
if( nvIdx != -1 ) platform = pIdx[nvIdx];
else platform = pIdx[atiIdx];
else if(atiIdx != -1) platform = pIdx[atiIdx];
else platform = pIdx[0];
}
else if( deviceType == CL_DEVICE_TYPE_CPU )
{
......@@ -335,7 +337,7 @@ inline void DeviceUtilsCL::waitForCompletion( const DeviceDataBase* deviceDataBa
}
template<>
inline KernelBuilderCL::KernelBuilder( const DeviceDataBase* deviceDataBase, char* fileName, const char* option, bool addExtension )
inline KernelBuilderCL::KernelBuilder( const DeviceDataBase* deviceDataBase, const char* fileName, const char* option, bool addExtension )
{
char fileNameWithExtension[256];
......@@ -375,7 +377,7 @@ inline KernelBuilderCL::KernelBuilder( const DeviceDataBase* deviceDataBase, cha
str = new char[size + 1];
if (!str) {
f.close();
return NULL;
return false;
}
// Read file
......
......@@ -26,7 +26,7 @@ public:
class Builder : public KernelBuilder<KERNEL>
{
public:
Builder( const DeviceDataBase* deviceData, char* fileName, const char* option = NULL, bool addExtension = false ): KernelBuilder<KERNEL>(deviceData, fileName, option, addExtension){}
Builder( const DeviceDataBase* deviceData, const char* fileName, const char* option = NULL, bool addExtension = false ): KernelBuilder<KERNEL>(deviceData, fileName, option, addExtension){}
};
class Launcher : public KernelLauncher<BUFFER, KERNEL>
......
......@@ -65,8 +65,8 @@ Dem2Demo::Dem2Demo(const DeviceDataBase* deviceData)
m_constBuffer.allocate<ConstBuffer>( m_deviceData, 1, DeviceBufferBase::BUFFER_CONST );
{
const char *option = "-I ..\\";
DKernelBuilder builder( m_deviceData, "Demos\\Dem2Demo", option, true );
const char *option = "-I ../";
DKernelBuilder builder( m_deviceData, "Demos/Dem2Demo", option, true );
builder.createKernel("CollideGridKernel", m_collisionKernel );
builder.createKernel("IntegrateKernel", m_integrateKernel );
......
......@@ -26,9 +26,9 @@ UniformGrid<DEVICEBUFFER,DEVICEKERNEL>::UniformGrid( const DeviceDataBase* devic
}
{
const char *option = "-I ..\\";
const char *option = "-I ../";
typename DUtilsBase<DEVICEBUFFER, DEVICEKERNEL>::Builder builder( m_deviceData, "Demos\\UniformGridKernels", option, true );
typename DUtilsBase<DEVICEBUFFER, DEVICEKERNEL>::Builder builder( m_deviceData, "Demos/UniformGridKernels", option, true );
builder.createKernel("GridClearKernel", m_gridClearKernel );
builder.createKernel("GridConstructionKernel", m_gridConstructionKernel );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment