Hi Everyone,
I just tried to post this, but the cancel button is right below the tags control, and doesn't have a confirmation action, so I think I lost it. If this is a double post due to some kind of moderation delay apologies in advance...
Anyway, on to the issue at hand. I have some Swift 1.2 code for OpenCL that I'm working on porting to Swift 2, and I'm having some trouble with the type system. The way that OpenCL is bridged into swift relies heavily on typedefs, and there are a TON!! of them. I had to perform some gymnastics in 1.2 to convince the type system that my argument is just the right kind of UInt32 (or is it cl_device_info?), but now those aren't enough in 2.
A short sample of (some of!) the suspect code follows. There are about 50 instances of this kind of error in the project:
private class func deviceInfoString(deviceID: cl_device_id, param paramIn: Int32) throws -> String {
let param = cl_device_info(paramIn)
var returnBufferSize: Int = 0
var retval: cl_int = CL_SUCCESS
retval = clGetDeviceInfo(deviceID, paramIn, 0, nil, &returnBufferSize)
if retval != CL_SUCCESS {
throw OSUOpenCLError.deviceStringQueryError(optional: SwiftOpenCL.printCLError(retval))
}
var buffer: [CChar] = Array<CChar>(count: Int(returnBufferSize),
repeatedValue: CChar(0x00))
retval = clGetDeviceInfo(deviceID, paramIn, returnBufferSize, &buffer, nil)
if retval != CL_SUCCESS {
throw OSUOpenCLError.deviceStringQueryError(optional: SwiftOpenCL.printCLError(retval))
}
if let str = String(UTF8String: buffer) {
return str
} else {
throw OSUOpenCLError.deviceStringQueryError(optional: "Unable to convert byte buffer into string")
}
}
The input argument param/paramIn is because all the OpenCL CL_DEVICE_NAME constants are defined as Int32's, and rather than cast them everywhere into cl_device_info, I do it once, here. The error I'm getting is:
/Users/wdillon/Documents/Source Code/Thesis/OSUOpenCL/OSUOpenCL/OSUOpenCLDevice.swift:79:18: error: cannot invoke 'clGetDeviceInfo' with an argument list of type '(cl_device_id, Int32, Int, nil, inout Int)'
retval = clGetDeviceInfo(deviceID, paramIn, 0, nil, &returnBufferSize)
^
/Users/wdillon/Documents/Source Code/Thesis/OSUOpenCL/OSUOpenCL/OSUOpenCLDevice.swift:79:33: note: expected an argument list of type '(cl_device_id, cl_device_info, Int, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Int>)'
retval = clGetDeviceInfo(deviceID, paramIn, 0, nil, &returnBufferSize)
^
To condense that to just the type signatures:
clGetDeviceInfo(cl_device_id, Int32, Int, nil, inout Int)
clGetDeviceInfo(cl_device_id, cl_device_info, Int, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Int>)
I don't believe that problem is related to the pointers, because I've massaged them a fair amount to no avail.
Does anyone have any ideas??
Thanks in advance!