cl_createcontextfromtype.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012,2017,2018 CNRS
  4. * Copyright (C) 2010-2012,2016,2018 Université de Bordeaux
  5. * Copyright (C) 2011,2012 Inria
  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_SUFFIX__VERSION_1_0
  22. CL_API_ENTRY cl_context CL_API_CALL
  23. soclCreateContextFromType(const cl_context_properties * properties,
  24. cl_device_type device_type,
  25. void (*pfn_notify)(const char *, const void *, size_t, void *),
  26. void * user_data,
  27. cl_int * errcode_ret)
  28. {
  29. if (socl_init_starpu() < 0)
  30. return NULL;
  31. //TODO: appropriate error messages
  32. cl_uint num_devices;
  33. soclGetDeviceIDs(&socl_platform, device_type, 0, NULL, &num_devices);
  34. cl_device_id devices[num_devices];
  35. soclGetDeviceIDs(&socl_platform, device_type, num_devices, devices, NULL);
  36. return soclCreateContext(properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
  37. }