add timing of the OpenCL compile functions...they're really slow here, almost 20seconds total...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4449 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7a2bad4efb
commit
5e3fdf5067
|
@ -19,8 +19,11 @@
|
||||||
|
|
||||||
#include "OpenCL.h"
|
#include "OpenCL.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
|
namespace OpenCL
|
||||||
|
{
|
||||||
|
|
||||||
namespace OpenCL {
|
|
||||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||||
cl_device_id device_id = NULL;
|
cl_device_id device_id = NULL;
|
||||||
cl_context g_context = NULL;
|
cl_context g_context = NULL;
|
||||||
|
@ -29,7 +32,8 @@ namespace OpenCL {
|
||||||
|
|
||||||
bool g_bInitialized = false;
|
bool g_bInitialized = false;
|
||||||
|
|
||||||
bool Initialize() {
|
bool Initialize()
|
||||||
|
{
|
||||||
if(g_bInitialized)
|
if(g_bInitialized)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -66,23 +70,29 @@ bool Initialize() {
|
||||||
HandleCLError(err, "Failed to create a command commands!");
|
HandleCLError(err, "Failed to create a command commands!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//PanicAlert("Initialized OpenCL fine!");
|
|
||||||
|
NOTICE_LOG(COMMON, "Initialized OpenCL!");
|
||||||
g_bInitialized = true;
|
g_bInitialized = true;
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||||
cl_context GetContext() {
|
cl_context GetContext()
|
||||||
|
{
|
||||||
return g_context;
|
return g_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_command_queue GetCommandQueue() {
|
cl_command_queue GetCommandQueue()
|
||||||
|
{
|
||||||
return g_cmdq;
|
return g_cmdq;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_program CompileProgram(const char *Kernel) {
|
cl_program CompileProgram(const char *Kernel)
|
||||||
|
{
|
||||||
|
u32 compileStart = timeGetTime();
|
||||||
int err;
|
int err;
|
||||||
cl_program program;
|
cl_program program;
|
||||||
program = clCreateProgramWithSource(OpenCL::g_context, 1, (const char **) & Kernel, NULL, &err);
|
program = clCreateProgramWithSource(OpenCL::g_context, 1, (const char **) & Kernel, NULL, &err);
|
||||||
|
@ -103,11 +113,13 @@ cl_program CompileProgram(const char *Kernel) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NOTICE_LOG(COMMON, "OpenCL CompileProgram took %.3f seconds", (float)(timeGetTime() - compileStart) / 1000.0);
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_kernel CompileKernel(cl_program program, const char *Function)
|
cl_kernel CompileKernel(cl_program program, const char *Function)
|
||||||
{
|
{
|
||||||
|
u32 compileStart = timeGetTime();
|
||||||
int err;
|
int err;
|
||||||
// Create the compute kernel in the program we wish to run
|
// Create the compute kernel in the program we wish to run
|
||||||
//
|
//
|
||||||
|
@ -117,11 +129,13 @@ cl_kernel CompileKernel(cl_program program, const char *Function)
|
||||||
HandleCLError(err, "Failed to create compute kernel!");
|
HandleCLError(err, "Failed to create compute kernel!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
NOTICE_LOG(COMMON, "OpenCL CompileKernel took %.3f seconds", (float)(timeGetTime() - compileStart) / 1000.0);
|
||||||
return kernel;
|
return kernel;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
void Destroy() {
|
|
||||||
|
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||||
if(!g_context)
|
if(!g_context)
|
||||||
return;
|
return;
|
||||||
|
@ -130,9 +144,10 @@ void Destroy() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
|
||||||
void HandleCLError(cl_int error, char* str)
|
void HandleCLError(cl_int error, char* str)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||||
|
|
||||||
char* name;
|
char* name;
|
||||||
switch(error)
|
switch(error)
|
||||||
{
|
{
|
||||||
|
@ -191,7 +206,7 @@ void HandleCLError(cl_int error, char* str)
|
||||||
str = "";
|
str = "";
|
||||||
PanicAlert("OpenCL error: %s %s (%d)", str, name, error);
|
PanicAlert("OpenCL error: %s %s (%d)", str, name, error);
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
|
@ -40,10 +40,13 @@ typedef void *cl_command_queue;
|
||||||
typedef void *cl_program;
|
typedef void *cl_program;
|
||||||
typedef void *cl_kernel;
|
typedef void *cl_kernel;
|
||||||
typedef void *cl_mem;
|
typedef void *cl_mem;
|
||||||
|
typedef void *cl_int;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace OpenCL {
|
namespace OpenCL
|
||||||
|
{
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||||
extern cl_device_id device_id;
|
extern cl_device_id device_id;
|
||||||
extern cl_context g_context;
|
extern cl_context g_context;
|
||||||
|
@ -61,9 +64,7 @@ void Destroy();
|
||||||
cl_program CompileProgram(const char *Kernel);
|
cl_program CompileProgram(const char *Kernel);
|
||||||
cl_kernel CompileKernel(cl_program program, const char *Function);
|
cl_kernel CompileKernel(cl_program program, const char *Function);
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
|
||||||
void HandleCLError(cl_int error, char* str = 0);
|
void HandleCLError(cl_int error, char* str = 0);
|
||||||
#endif
|
}
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue