summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/OpenCL.cpp
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2009-10-22 03:53:47 +0000
committerShawn Hoffman <godisgovernment@gmail.com>2009-10-22 03:53:47 +0000
commit5e3fdf5067a6c9823645d9dcced829169145af9e (patch)
treef0f93a2c9aae63b922d76be44f4cabc57582edb7 /Source/Core/Common/Src/OpenCL.cpp
parent7a2bad4efbe62058460494a6e2ce6df26d198450 (diff)
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
Diffstat (limited to 'Source/Core/Common/Src/OpenCL.cpp')
-rw-r--r--Source/Core/Common/Src/OpenCL.cpp109
1 files changed, 62 insertions, 47 deletions
diff --git a/Source/Core/Common/Src/OpenCL.cpp b/Source/Core/Common/Src/OpenCL.cpp
index c3ff939ab0..37ffb9d028 100644
--- a/Source/Core/Common/Src/OpenCL.cpp
+++ b/Source/Core/Common/Src/OpenCL.cpp
@@ -19,17 +19,21 @@
#include "OpenCL.h"
#include "Common.h"
+#include "Timer.h"
-namespace OpenCL {
- #if defined(HAVE_OPENCL) && HAVE_OPENCL
- cl_device_id device_id = NULL;
- cl_context g_context = NULL;
- cl_command_queue g_cmdq = NULL;
- #endif
+namespace OpenCL
+{
+
+#if defined(HAVE_OPENCL) && HAVE_OPENCL
+cl_device_id device_id = NULL;
+cl_context g_context = NULL;
+cl_command_queue g_cmdq = NULL;
+#endif
bool g_bInitialized = false;
-bool Initialize() {
+bool Initialize()
+{
if(g_bInitialized)
return true;
@@ -66,62 +70,72 @@ bool Initialize() {
HandleCLError(err, "Failed to create a command commands!");
return false;
}
- //PanicAlert("Initialized OpenCL fine!");
+
+ NOTICE_LOG(COMMON, "Initialized OpenCL!");
g_bInitialized = true;
return true;
#else
return false;
#endif
}
+
#if defined(HAVE_OPENCL) && HAVE_OPENCL
-cl_context GetContext() {
+cl_context GetContext()
+{
return g_context;
}
-cl_command_queue GetCommandQueue() {
+cl_command_queue GetCommandQueue()
+{
return g_cmdq;
}
-cl_program CompileProgram(const char *Kernel) {
- int err;
- cl_program program;
- program = clCreateProgramWithSource(OpenCL::g_context, 1, (const char **) & Kernel, NULL, &err);
- if (!program)
- {
- HandleCLError(err, "Error: Failed to create compute program!");
- return NULL;
- }
-
- // Build the program executable
- //
- err = clBuildProgram(program , 0, NULL, NULL, NULL, NULL);
- if(err != CL_SUCCESS) {
- char *errors[16384] = {0};
- err = clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, sizeof(errors),
- errors, NULL);
- PanicAlert("Error log:\n%s\n", errors);
- return NULL;
- }
-
-
- return program;
+cl_program CompileProgram(const char *Kernel)
+{
+ u32 compileStart = timeGetTime();
+ int err;
+ cl_program program;
+ program = clCreateProgramWithSource(OpenCL::g_context, 1, (const char **) & Kernel, NULL, &err);
+ if (!program)
+ {
+ HandleCLError(err, "Error: Failed to create compute program!");
+ return NULL;
+ }
+
+ // Build the program executable
+ //
+ err = clBuildProgram(program , 0, NULL, NULL, NULL, NULL);
+ if(err != CL_SUCCESS) {
+ char *errors[16384] = {0};
+ err = clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, sizeof(errors),
+ errors, NULL);
+ PanicAlert("Error log:\n%s\n", errors);
+ return NULL;
+ }
+
+ NOTICE_LOG(COMMON, "OpenCL CompileProgram took %.3f seconds", (float)(timeGetTime() - compileStart) / 1000.0);
+ return program;
}
+
cl_kernel CompileKernel(cl_program program, const char *Function)
{
- int err;
- // Create the compute kernel in the program we wish to run
- //
- cl_kernel kernel = clCreateKernel(program, Function, &err);
- if (!kernel || err != CL_SUCCESS)
- {
- HandleCLError(err, "Failed to create compute kernel!");
- return NULL;
- }
- return kernel;
+ u32 compileStart = timeGetTime();
+ int err;
+ // Create the compute kernel in the program we wish to run
+ //
+ cl_kernel kernel = clCreateKernel(program, Function, &err);
+ if (!kernel || err != CL_SUCCESS)
+ {
+ HandleCLError(err, "Failed to create compute kernel!");
+ return NULL;
+ }
+ NOTICE_LOG(COMMON, "OpenCL CompileKernel took %.3f seconds", (float)(timeGetTime() - compileStart) / 1000.0);
+ return kernel;
}
#endif
-void Destroy() {
+void Destroy()
+{
#if defined(HAVE_OPENCL) && HAVE_OPENCL
if(!g_context)
return;
@@ -130,9 +144,10 @@ void Destroy() {
#endif
}
-#if defined(HAVE_OPENCL) && HAVE_OPENCL
void HandleCLError(cl_int error, char* str)
{
+#if defined(HAVE_OPENCL) && HAVE_OPENCL
+
char* name;
switch(error)
{
@@ -191,7 +206,7 @@ void HandleCLError(cl_int error, char* str)
str = "";
PanicAlert("OpenCL error: %s %s (%d)", str, name, error);
-}
#endif
+}
-};
+}