Dear Xavier
I am very happy for your work on the FortranCL code.
I am myself likely to go deeper into this.
Scouring the code I came to the conclusion that some small features were missing.
I have then subsequently tried to add code to circumvent this.
When I add something I will try and send it your way once it has stabilized.
The clGetDeviceInfo should be capable of returning the platform where the device resides.
For this I created an extension for the interface of clGetDeviceInfo
>> code for interface in cl_device.f90
subroutine clgetdeviceinfo_platform(device, param_name, param_value, errcode_ret)
use cl_types_m
implicit none
type(cl_device_id), intent(in) :: device
integer, intent(in) :: param_name
type(cl_platform_id),intent(out) :: param_value
integer, intent(out) :: errcode_ret
end subroutine clgetdeviceinfo_platform
<<<
This required a low level code which is provided as such:
>>> code for cl_device_low.c
void FC_FUNC_(clgetdeviceinfo_platform, CLGETDEVICEINFO_PLATFORM)
(const cl_device_id * device, const int * param_name, cl_platform_id * param_value, int * status){
//size_t length; // needed for the error testing
if ( *param_name != CL_DEVICE_PLATFORM ) {
fprintf(stderr,"clGetDeviceInfo() for cl_platform_id requires CL_DEVICE_PLATFORM\n");
exit(1);
}
/* The following length lookup will produce an error
* I have no idea why...
*status = (int) clGetDeviceInfo(*device, (cl_device_info) *param_name, 0, NULL, &length);
*/
//if ( *status != CL_SUCCESS) {
// fprintf(stderr,"clGetDeviceInfo() failed, result = %d\n", *status);
// exit(1);
//}
*status = (int) clGetDeviceInfo(*device, (cl_device_info) *param_name, sizeof(cl_platform_id), param_value, NULL);
}
<<<
The above code makes errors for CL_INVALID_VALUE in the code which is commented out, which makes no sense as the CL_DEVICE_PLATFORM is defined in the CL standard.
Also the fact that the variable `length` gets returned with the correct size (8) of the cl_platform_id makes me wonder about the underlying cl functions?
If we simply remove the length retrieval, the code will perform as expected!
Hope you can use this. I find it useful to only pass around devices and through them retrieve the platform (if that is required).
Kind regards Nick