title: Error CL_DEVICE_NOT_AVAILABLE when calling clCreateContext (Intel Core2Duo, Intel OCL SDK 3.0 beta)
body: <p>I'm trying to get started with OpenCL (Intel opencl-1.2-3.0.56860). I managed to install the OpenCL SDK from Intel under Ubuntu 12.05 (using "alien" to convert the rpm packages to *.deb packages). Now I try to get my first simple OpenCL program running... To run the program I need to use set the LD_LIBRARY_PATH:</p>
  
  <pre><code>export LD_LIBRARY_PATH=/opt/intel/opencl/lib64/
  </code></pre>
  
  <p>My Problem is, that I always get the error "CL_DEVICE_NOT_AVAILABLE" when calling clCreateContext(...).</p>
  
  <p>Here is my source code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include &lt;CL/cl.h&gt;
  #include &lt;CL/cl_platform.h&gt;
  #include &lt;string.h&gt;
  
  // Enable double precision values
  #pragma OPENCL EXTENSION cl_khr_fp64 : enable
  
  // OpenCL kernel. Each work item takes care of one element of c
  const char *kernelSource =                                      "\n" \
  "__kernel void vecAdd(  __global double *a,                       \n" \
  "                       __global double *b,                       \n" \
  "                       __global double *c,                       \n" \
  "                       const unsigned int n)                    \n" \
  "{                                                               \n" \
  "    //Get our global thread ID                                  \n" \
  "    int id = get_global_id(0);                                  \n" \
  "                                                                \n" \
  "    //Make sure we do not go out of bounds                      \n" \
  "    if (id &lt; n)                                                 \n" \
  "        c[id] = a[id] + b[id];                                  \n" \
  "}                                                               \n" \
                                                                  "\n" ;
  
  const char* err2str(cl_int err) {
    switch(err) {
    case CL_SUCCESS: return "CL_SUCCESS";
    case CL_INVALID_PROGRAM: return "CL_INVALID_PROGRAM";
    case CL_INVALID_VALUE: return "CL_INVALID_VALUE";
    case CL_INVALID_DEVICE: return "CL_INVALID_DEVICE";
    case CL_INVALID_BINARY: return "CL_INVALID_BINARY";
    case CL_INVALID_BUILD_OPTIONS: return "CL_INVALID_BUILD_OPTIONS";
    case CL_INVALID_OPERATION: return "CL_INVALID_OPERATION";
    case CL_DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE";
    default: return "unknown";
    }
  }
  
  void pfn_notify(const char *errinfo, const void *private_info, size_t cb, void *user_data)
  {
    fprintf(stderr, "OpenCL Error (via pfn_notify): %s\n", errinfo);
  }
  
  cl_platform_id GetIntelOCLPlatform()
  {
      cl_platform_id pPlatforms[10] = { 0 };
      char pPlatformName[128] = { 0 };
  
      cl_uint uiPlatformsCount = 0;
      cl_int err = clGetPlatformIDs(10, pPlatforms, &amp;uiPlatformsCount);
      for (cl_uint ui = 0; ui &lt; uiPlatformsCount; ++ui)
      {
          err = clGetPlatformInfo(pPlatforms[ui], CL_PLATFORM_NAME, 128 * sizeof(char), pPlatformName, NULL);
          if ( err != CL_SUCCESS )
          {
              printf("ERROR: Failed to retreive platform vendor name.\n", ui);
              return NULL;
          }
  
          if (!strcmp(pPlatformName, "Intel(R) OpenCL"))
              return pPlatforms[ui];
      }
  
      return NULL;
  }
  
  int main( int argc, char* argv[] )
  {
      cl_platform_id cpPlatform;        // OpenCL platform
      cl_device_id device_id;           // device ID
      cl_context context;               // context
      cl_command_queue queue;           // command queue
      cl_program program;               // program
      cl_kernel kernel;                 // kernel
      size_t cb;
      cl_device_id devices[100];
      cl_uint devices_n = 0;
      cl_int err;
  
  
      cl_platform_id intel_platform_id = GetIntelOCLPlatform();
      if( intel_platform_id == NULL ) {
        printf("ERROR: Failed to find Intel OpenCL platform.\n");
        return -1;
      }
  
      // Get Device Info...
      err = clGetDeviceIDs(intel_platform_id, CL_DEVICE_TYPE_ALL, 100, devices, &amp;devices_n);
      printf("ERR(clGetDeviceIDs) = %d\n", err);
      printf("#DEVICES: %d\n", devices_n);
  
  
      for (int i=0; i&lt;devices_n; i++) {
         char buffer[10240];
         cl_uint buf_uint;
         cl_ulong buf_ulong;
         printf("  -- %d --\n", i);
         err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(buffer), buffer, NULL);
         printf("  DEVICE_NAME = %s\n", buffer);
         err = clGetDeviceInfo(devices[i], CL_DEVICE_VENDOR, sizeof(buffer), buffer, NULL);
         printf("  DEVICE_VENDOR = %s\n", buffer);
         err = clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, sizeof(buffer), buffer, NULL);
         printf("  DEVICE_VERSION = %s\n", buffer);
         err = clGetDeviceInfo(devices[i], CL_DRIVER_VERSION, sizeof(buffer), buffer, NULL);
         printf("  DRIVER_VERSION = %s\n", buffer);
         err = clGetDeviceInfo(devices[i], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(buf_uint), &amp;buf_uint, NULL);
         printf("  DEVICE_MAX_COMPUTE_UNITS = %u\n", (unsigned int)buf_uint);
         err = clGetDeviceInfo(devices[i], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(buf_uint), &amp;buf_uint, NULL);
         printf("  DEVICE_MAX_CLOCK_FREQUENCY = %u\n", (unsigned int)buf_uint);
         err = clGetDeviceInfo(devices[i], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(buf_ulong), &amp;buf_ulong, NULL);
         printf("  DEVICE_GLOBAL_MEM_SIZE = %llu\n", (unsigned long long)buf_ulong);
      }
  
      context = clCreateContext(NULL, 1, devices, &amp;pfn_notify, NULL, &amp;err);
      printf("ERR(clCreateContext) = %d [%s]\n", err, err2str(err));
  
  
      // Create a context
      cl_context_properties context_properties[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties)intel_platform_id, (cl_context_properties)NULL };
  
  //    context = clCreateContext(0, 1, &amp;device_id, NULL, NULL, &amp;err);
      context = clCreateContextFromType(context_properties, CL_DEVICE_TYPE_CPU, NULL, NULL, &amp;err);
      printf("ERR(clCreateContextFromType) = %d [%s]\n", err, err2str(err));
      if (err != CL_SUCCESS) exit(0);
  
      if (context == (cl_context)0) {
        printf("Illegal context?");
        exit(0);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>The Output is:</p>
  
  <pre><code>ERR(clGetDeviceIDs) = 0
  #DEVICES: 1
    -- 0 --
    DEVICE_NAME = Intel(R) Core(TM)2 Duo CPU     P7450  @ 2.13GHz
    DEVICE_VENDOR = Intel(R) Corporation
    DEVICE_VERSION = OpenCL 1.2 (Build 56860)
    DRIVER_VERSION = 1.2
    DEVICE_MAX_COMPUTE_UNITS = 2
    DEVICE_MAX_CLOCK_FREQUENCY = 2130
    DEVICE_GLOBAL_MEM_SIZE = 3152510976
  ERR(clCreateContext) = -2 [CL_DEVICE_NOT_AVAILABLE]
  ERR(clCreateContextFromType) = -2 [CL_DEVICE_NOT_AVAILABLE]
  </code></pre>
  
  <p>Any Ideas how to solve that?</p>
  
  <p>Regards,
  Stefan</p>
  
  <p><strong>---- EDIT -----</strong></p>
  
  <p>The CPU has the sse4_1 flag (also: sse, sse2, sss3).</p>
  
  <p>cat /proc/cpuinfo</p>
  
  <pre><code>processor       : 0
  vendor_id       : GenuineIntel
  cpu family      : 6
  model           : 23
  model name      : Intel(R) Core(TM)2 Duo CPU     P7450  @ 2.13GHz
  stepping        : 6
  microcode       : 0x60c
  cpu MHz         : 800.000
  cache size      : 3072 KB
  physical id     : 0
  siblings        : 2
  core id         : 0
  cpu cores       : 2
  apicid          : 0
  initial apicid  : 0
  fpu             : yes
  fpu_exception   : yes
  cpuid level     : 10
  wp              : yes
  flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm dtherm
  bogomips        : 4255.56
  clflush size    : 64
  cache_alignment : 64
  address sizes   : 36 bits physical, 48 bits virtual
  power management:
  
  [ same for the other core]
  </code></pre>