[Mesa-dev] [PATCH] clover: Support multiple devices in clCreateContextFromType()

Tom Stellard tom at stellard.net
Tue May 14 14:08:07 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

---
 src/gallium/state_trackers/clover/api/context.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/context.cpp b/src/gallium/state_trackers/clover/api/context.cpp
index 3717441..e0fed31 100644
--- a/src/gallium/state_trackers/clover/api/context.cpp
+++ b/src/gallium/state_trackers/clover/api/context.cpp
@@ -22,6 +22,7 @@
 
 #include "api/util.hpp"
 #include "core/context.hpp"
+#include "core/platform.hpp"
 
 using namespace clover;
 
@@ -63,18 +64,22 @@ clCreateContextFromType(const cl_context_properties *props,
                         void *user_data, cl_int *errcode_ret) try {
    cl_platform_id platform;
    cl_uint num_platforms;
-   cl_device_id dev;
    cl_int ret;
+   std::vector<cl_device_id> devs;
 
    ret = clGetPlatformIDs(1, &platform, &num_platforms);
    if (ret || !num_platforms)
       throw error(CL_INVALID_PLATFORM);
 
-   ret = clGetDeviceIDs(platform, type, 1, &dev, 0);
-   if (ret)
+   if (platform->begin() == platform->end())
       throw error(CL_DEVICE_NOT_FOUND);
 
-   return clCreateContext(props, 1, &dev, pfn_notify, user_data, errcode_ret);
+   for (clover::platform::iterator i = platform->begin(), e = platform->end();
+                                                         i != e; ++i) {
+      devs.push_back(&*i);
+   }
+
+   return clCreateContext(props, devs.size(), devs.data(), pfn_notify, user_data, errcode_ret);
 
 } catch(error &e) {
    ret_error(errcode_ret, e);
-- 
1.7.11.4



More information about the mesa-dev mailing list