cl_createcontextfromtype.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2012 Inria
  4. * Copyright (C) 2012,2017 CNRS
  5. * Copyright (C) 2010-2012,2016 Université de Bordeaux
  6. * Copyright (C) 2012 Vincent Danjean
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #include "socl.h"
  20. #include "init.h"
  21. CL_API_ENTRY cl_context CL_API_CALL
  22. soclCreateContextFromType(const cl_context_properties * properties,
  23. cl_device_type device_type,
  24. void (*pfn_notify)(const char *, const void *, size_t, void *),
  25. void * user_data,
  26. cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0
  27. {
  28. if (socl_init_starpu() < 0)
  29. return NULL;
  30. //TODO: appropriate error messages
  31. cl_uint num_devices;
  32. soclGetDeviceIDs(&socl_platform, device_type, 0, NULL, &num_devices);
  33. cl_device_id devices[num_devices];
  34. soclGetDeviceIDs(&socl_platform, device_type, num_devices, devices, NULL);
  35. return soclCreateContext(properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
  36. }