[Libreoffice-commits] core.git: Branch 'feature/calc-pluggable-opencl' - sc/workben

2013-09-12 Thread Kohei Yoshida
 sc/workben/opencl/platform_detect.cxx |   71 ++
 1 file changed, 71 insertions(+)

New commits:
commit 798cf059bd5ee25fbc8b0d26a69ed8d1ea24b32b
Author: Kohei Yoshida 
Date:   Thu Sep 12 16:13:19 2013 -0400

Add a quick test code to detect available OpenCL platforms.

Compile this with clew files from source/core/opencl/clcc.

Change-Id: I9a0be046ec996a6bccdcc8555aa8119fcf9afde3

diff --git a/sc/workben/opencl/platform_detect.cxx 
b/sc/workben/opencl/platform_detect.cxx
new file mode 100755
index 000..81c19e6
--- /dev/null
+++ b/sc/workben/opencl/platform_detect.cxx
@@ -0,0 +1,71 @@
+#include 
+#include 
+#include 
+#include 
+
+#include "clew.h"
+
+using namespace std;
+
+int main()
+{
+const char* dllname = "OpenCL.dll"; // from GPU driver.
+//  const char* dllname = "amdocl.dll"; // from AMD SDK
+//  const char* dllname = "intelocl.dll"; // from Intel SDK
+int status = clewInit(dllname);
+if (status < 0)
+{
+cout << "failed to load" << endl;
+return EXIT_FAILURE;
+}
+
+cout << "OpenCL.dll loaded successfully." << endl;
+
+cl_uint platformCount = 0;
+clGetPlatformIDs(0, NULL, &platformCount);
+
+cout << "number of platforms: " << platformCount << endl;
+vector platformIDs(platformCount);
+if (clGetPlatformIDs(platformCount, &platformIDs[0], NULL) != CL_SUCCESS)
+{
+cout << "failed to get platform IDs" << endl;
+return EXIT_FAILURE;
+}
+
+for (size_t i = 0, n = platformIDs.size(); i < n; ++i)
+{
+cout << "* platform (ID=" << platformIDs[i] << ")" << endl;
+string param(100, '\0');
+if (clGetPlatformInfo(platformIDs[i], CL_PLATFORM_PROFILE, 
param.size(), ¶m[0], NULL) == CL_SUCCESS)
+cout << "  profile: " << param.c_str() << endl;
+if (clGetPlatformInfo(platformIDs[i], CL_PLATFORM_VERSION, 
param.size(), ¶m[0], NULL) == CL_SUCCESS)
+cout << "  version: " << param.c_str() << endl;
+if (clGetPlatformInfo(platformIDs[i], CL_PLATFORM_NAME, param.size(), 
¶m[0], NULL) == CL_SUCCESS)
+cout << "  name: " << param.c_str() << endl;
+if (clGetPlatformInfo(platformIDs[i], CL_PLATFORM_VENDOR, 
param.size(), ¶m[0], NULL) == CL_SUCCESS)
+cout << "  vendor: " << param.c_str() << endl;
+if (clGetPlatformInfo(platformIDs[i], CL_PLATFORM_EXTENSIONS, 
param.size(), ¶m[0], NULL) == CL_SUCCESS)
+cout << "  extensions: " << param.c_str() << endl;
+
+cl_uint deviceCount = 0;
+clGetDeviceIDs(platformIDs[i], CL_DEVICE_TYPE_ALL, 0, NULL, 
&deviceCount);
+cout << "  number of devices: " << deviceCount << endl;
+
+vector deviceIDs(deviceCount);
+if (clGetDeviceIDs(platformIDs[i], CL_DEVICE_TYPE_ALL, deviceCount, 
&deviceIDs[0], NULL) != CL_SUCCESS)
+continue;
+
+for (size_t j = 0; j < deviceIDs.size(); ++j)
+{
+cout << "  * device (ID=" << deviceIDs[j] << ")" << endl;
+if (clGetDeviceInfo(deviceIDs[j], CL_DEVICE_VENDOR, param.size(), 
¶m[0], NULL) == CL_SUCCESS)
+cout << "vendor: " << param.c_str() << endl;
+if (clGetDeviceInfo(deviceIDs[j], CL_DEVICE_VERSION, param.size(), 
¶m[0], NULL) == CL_SUCCESS)
+cout << "version: " << param.c_str() << endl;
+if (clGetDeviceInfo(deviceIDs[j], CL_DRIVER_VERSION, param.size(), 
¶m[0], NULL) == CL_SUCCESS)
+cout << "driver version: " << param.c_str() << endl;
+}
+}
+
+return EXIT_SUCCESS;
+}
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/calc-pluggable-opencl' - sc/workben

2013-09-12 Thread Kohei Yoshida
 sc/workben/opencl/platform_detect.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit a0f1577167e17ef7af54b45c4b96f7a06410041f
Author: Kohei Yoshida 
Date:   Thu Sep 12 18:03:34 2013 -0400

On linux, the entry library name is 'libOpenCL.so'.

And it should be installed in the system library path, so no need to
specify full path to load it.

Change-Id: I0a77bd6911e69f8453b7c95c7cdcb77fe2e6e5e0

diff --git a/sc/workben/opencl/platform_detect.cxx 
b/sc/workben/opencl/platform_detect.cxx
index 81c19e6..b0a9c61 100755
--- a/sc/workben/opencl/platform_detect.cxx
+++ b/sc/workben/opencl/platform_detect.cxx
@@ -9,7 +9,8 @@ using namespace std;
 
 int main()
 {
-const char* dllname = "OpenCL.dll"; // from GPU driver.
+const char* dllname = "libOpenCL.so"; // on Linux
+//  const char* dllname = "OpenCL.dll"; // from GPU driver.
 //  const char* dllname = "amdocl.dll"; // from AMD SDK
 //  const char* dllname = "intelocl.dll"; // from Intel SDK
 int status = clewInit(dllname);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits