Browse Source

SOCL: support context properties (scheduler and context name)

Sylvain Henry 12 years ago
parent
commit
0af8e83af4
2 changed files with 33 additions and 3 deletions
  1. 30 3
      socl/src/cl_createcontext.c
  2. 3 0
      socl/src/socl.h

+ 30 - 3
socl/src/cl_createcontext.c

@@ -60,6 +60,16 @@ soclCreateContext(const cl_context_properties * properties,
                   return NULL;
                   return NULL;
                }
                }
                break;
                break;
+
+            case CL_CONTEXT_SCHEDULER_SOCL:
+            case CL_CONTEXT_NAME_SOCL:
+               i++;
+               if (p[i] == NULL) {
+                  if (errcode_ret != NULL)
+                     *errcode_ret = CL_INVALID_PROPERTY;
+                  return NULL;
+               }
+               break;
          }
          }
          i++;
          i++;
       }
       }
@@ -77,8 +87,12 @@ soclCreateContext(const cl_context_properties * properties,
    ctx->num_properties = 0;
    ctx->num_properties = 0;
    ctx->properties = NULL;
    ctx->properties = NULL;
 
 
-   // Cache properties
+   char * scheduler = "dmda";
+   char * name = "default";
+
+   // Properties
    if (properties != NULL) {
    if (properties != NULL) {
+
       //Count properties
       //Count properties
       const cl_context_properties * p = properties;
       const cl_context_properties * p = properties;
       do {
       do {
@@ -89,6 +103,20 @@ soclCreateContext(const cl_context_properties * properties,
       //Copy properties
       //Copy properties
       ctx->properties = malloc(sizeof(cl_context_properties) * ctx->num_properties);
       ctx->properties = malloc(sizeof(cl_context_properties) * ctx->num_properties);
       memcpy(ctx->properties, properties, sizeof(cl_context_properties) * ctx->num_properties);
       memcpy(ctx->properties, properties, sizeof(cl_context_properties) * ctx->num_properties);
+
+      //Selected scheduler
+      int i = 0;
+      for (i=0; i<ctx->num_properties; i++) {
+         if (p[i] == CL_CONTEXT_SCHEDULER_SOCL) {
+            i++;
+            scheduler = p[i];
+         }
+         if (p[i] == CL_CONTEXT_NAME_SOCL) {
+            i++;
+            name = p[i];
+         }
+      }
+
    }
    }
 
 
    ctx->pfn_notify = pfn_notify;
    ctx->pfn_notify = pfn_notify;
@@ -109,8 +137,7 @@ soclCreateContext(const cl_context_properties * properties,
    for (i=0; i<num_devices; i++) {
    for (i=0; i<num_devices; i++) {
       workers[i] = ctx->devices[i]->worker_id;
       workers[i] = ctx->devices[i]->worker_id;
    }
    }
-   //TODO use context property to set scheduling strategy and name
-   ctx->sched_ctx = starpu_sched_ctx_create("dmda", workers, num_devices, "ctx");
+   ctx->sched_ctx = starpu_sched_ctx_create(scheduler, workers, num_devices, name);
 
 
    if (errcode_ret != NULL)
    if (errcode_ret != NULL)
       *errcode_ret = CL_SUCCESS;
       *errcode_ret = CL_SUCCESS;

+ 3 - 0
socl/src/socl.h

@@ -18,6 +18,9 @@
 #ifndef SOCL_H
 #ifndef SOCL_H
 #define SOCL_H
 #define SOCL_H
 
 
+#define CL_CONTEXT_SCHEDULER_SOCL   0xFF01
+#define CL_CONTEXT_NAME_SOCL        0xFF02
+
 #include <string.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdint.h>