func (p *Platform) CreateContextFromType(device_type DeviceType) (*Context, error) { if device_type == DeviceTypeCPU || device_type == DeviceTypeGPU || device_type == DeviceTypeAccelerator || device_type == DeviceTypeDefault || device_type == DeviceTypeAll { var properties []C.cl_context_properties defer C.free(properties) properties = append(properties, C.CL_CONTEXT_PLATFORM) properties = append(properties, (C.platform_id_convert(p.id))) properties = append(properties, (C.cl_context_properties)(0)) ctx, err := CreateContextFromTypeUnsafe(&properties[0], device_type.toCl(), nil, nil) return ctx, err } return nil, toError(C.CL_INVALID_DEVICE) }
func (p *Platform) CreateContext(devList []*Device) (*Context, error) { if devList != nil { var properties []C.cl_context_properties defer C.free(properties) properties = append(properties, C.CL_CONTEXT_PLATFORM) properties = append(properties, (C.platform_id_convert(p.id))) properties = append(properties, (C.cl_context_properties)(0)) ctx, err := CreateContextUnsafe(&properties[0], devList, nil, nil) return ctx, err } return nil, toError(C.CL_INVALID_DEVICE) }