本文整理匯總了Golang中C.cl_mem_flags函數的典型用法代碼示例。如果您正苦於以下問題:Golang cl_mem_flags函數的具體用法?Golang cl_mem_flags怎麽用?Golang cl_mem_flags使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了cl_mem_flags函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateImage
func (ctx *Context) CreateImage(flags MemFlag, imageFormat ImageFormat, imageDesc ImageDescription, data []byte) (*MemObject, error) {
format := imageFormat.toCl()
desc := imageDesc.toCl()
var dataPtr unsafe.Pointer
if data != nil {
dataPtr = unsafe.Pointer(&data[0])
}
var err C.cl_int
clBuffer := C.clCreateImage(ctx.clContext, C.cl_mem_flags(flags), &format, &desc, dataPtr, &err)
if err == C.CL_INVALID_OPERATION {
// retry with deprecated functions
switch imageDesc.Type {
case MemObjectTypeImage2D:
clBuffer = C.clCreateImage2D(ctx.clContext, C.cl_mem_flags(flags), &format,
C.size_t(imageDesc.Width), C.size_t(imageDesc.Height), C.size_t(imageDesc.RowPitch), dataPtr, &err)
}
}
if err != C.CL_SUCCESS {
return nil, toError(err)
}
if clBuffer == nil {
return nil, ErrUnknown
}
return newMemObject(clBuffer, len(data)), nil
}
示例2: CLCreateImage3D
func CLCreateImage3D(context CL_context,
flags CL_mem_flags,
image_format *CL_image_format,
image_width CL_size_t,
image_height CL_size_t,
image_depth CL_size_t,
image_row_pitch CL_size_t,
image_slice_pitch CL_size_t,
host_ptr unsafe.Pointer,
errcode_ret *CL_int) CL_mem {
var c_image_format C.cl_image_format
var c_errcode_ret C.cl_int
var c_image C.cl_mem
c_image_format.image_channel_order = C.cl_channel_order(image_format.Image_channel_order)
c_image_format.image_channel_data_type = C.cl_channel_type(image_format.Image_channel_data_type)
c_image = C.clCreateImage3D(context.cl_context,
C.cl_mem_flags(flags),
&c_image_format,
C.size_t(image_width),
C.size_t(image_height),
C.size_t(image_depth),
C.size_t(image_row_pitch),
C.size_t(image_slice_pitch),
host_ptr,
&c_errcode_ret)
if errcode_ret != nil {
*errcode_ret = CL_int(c_errcode_ret)
}
return CL_mem{c_image}
}
示例3: GetSupportedImageFormats
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetSupportedImageFormats.html
func GetSupportedImageFormats(context Context, flags MemFlags, memObjectType MemObjectType, numEntries uint32, imageformats *ImageFormat, numImageFormat *uint32) ErrorCode {
return ErrorCode(C.clGetSupportedImageFormats(context.clContext,
C.cl_mem_flags(flags),
C.cl_mem_object_type(memObjectType),
C.cl_uint(numEntries),
(*C.cl_image_format)(unsafe.Pointer(imageformats)),
(*C.cl_uint)(numImageFormat)))
}
示例4: CLGetSupportedImageFormats
func CLGetSupportedImageFormats(context CL_context,
flags CL_mem_flags,
image_type CL_mem_object_type,
num_entries CL_uint,
image_formats []CL_image_format,
num_image_formats *CL_uint) CL_int {
if (num_entries == 0 || image_formats == nil) && num_image_formats == nil {
return CL_INVALID_VALUE
} else {
var c_num_image_formats C.cl_uint
var c_errcode_ret C.cl_int
if num_entries == 0 || image_formats == nil {
c_errcode_ret = C.clGetSupportedImageFormats(context.cl_context,
C.cl_mem_flags(flags),
C.cl_mem_object_type(image_type),
C.cl_uint(num_entries),
nil,
&c_num_image_formats)
} else {
c_image_formats := make([]C.cl_image_format, len(image_formats))
c_errcode_ret = C.clGetSupportedImageFormats(context.cl_context,
C.cl_mem_flags(flags),
C.cl_mem_object_type(image_type),
C.cl_uint(num_entries),
&c_image_formats[0],
&c_num_image_formats)
if c_errcode_ret == C.CL_SUCCESS {
for i := 0; i < len(image_formats); i++ {
image_formats[i].Image_channel_data_type = CL_channel_type(c_image_formats[i].image_channel_data_type)
image_formats[i].Image_channel_order = CL_channel_order(c_image_formats[i].image_channel_order)
}
}
}
if num_image_formats != nil {
*num_image_formats = CL_uint(c_num_image_formats)
}
return CL_int(c_errcode_ret)
}
}
示例5: CreateBufferUnsafe
func (ctx *Context) CreateBufferUnsafe(flags MemFlag, size int, dataPtr unsafe.Pointer) (*MemObject, error) {
var err C.cl_int
clBuffer := C.clCreateBuffer(ctx.clContext, C.cl_mem_flags(flags), C.size_t(size), dataPtr, &err)
if err != C.CL_SUCCESS {
return nil, toError(err)
}
if clBuffer == nil {
return nil, ErrUnknown
}
return newMemObject(clBuffer, size), nil
}
示例6: CreateSubBuffer
func (mobj *MemObject) CreateSubBuffer(flags MemFlag, origin, bSize int) (*MemObject, error) {
var err C.cl_int
clBuffer := C.CLcreateSubBuffer(mobj.clMem, C.cl_mem_flags(flags), (C.size_t)(origin), (C.size_t)(bSize), &err)
if err != C.CL_SUCCESS {
return nil, toError(err)
}
if clBuffer == nil {
return nil, ErrUnknown
}
return newMemObject(clBuffer, bSize), nil
}
示例7: NewBuffer
func (c *Context) NewBuffer(flags MemFlags, size uint32) (*Buffer, error) {
var c_buffer C.cl_mem
var err C.cl_int
if c_buffer = C.clCreateBuffer(c.id, C.cl_mem_flags(flags), C.size_t(size), nil, &err); err != C.CL_SUCCESS {
return nil, Cl_error(err)
}
buffer := &Buffer{id: c_buffer}
runtime.SetFinalizer(buffer, (*Buffer).release)
return buffer, nil
}
示例8: GetSupportedImageFormats
func (ctx *Context) GetSupportedImageFormats(flags MemFlag, imageType MemObjectType) ([]ImageFormat, error) {
var formats [maxImageFormats]C.cl_image_format
var nFormats C.cl_uint
if err := C.clGetSupportedImageFormats(ctx.clContext, C.cl_mem_flags(flags), C.cl_mem_object_type(imageType), maxImageFormats, &formats[0], &nFormats); err != C.CL_SUCCESS {
return nil, toError(err)
}
fmts := make([]ImageFormat, nFormats)
for i, f := range formats[:nFormats] {
fmts[i] = ImageFormat{
ChannelOrder: ChannelOrder(f.image_channel_order),
ChannelDataType: ChannelDataType(f.image_channel_data_type),
}
}
return fmts, nil
}
示例9: CreateImage2D
func (ctx *Context) CreateImage2D(flags MemFlag, imageFormat ImageFormat, width, height, rowPitch int, data []byte) (*MemObject, error) {
format := imageFormat.toCl()
var dataPtr unsafe.Pointer
if data != nil {
dataPtr = unsafe.Pointer(&data[0])
}
var err C.cl_int
clBuffer := C.clCreateImage2D(ctx.clContext, C.cl_mem_flags(flags), &format, C.size_t(width), C.size_t(height), C.size_t(rowPitch), dataPtr, &err)
if err != C.CL_SUCCESS {
return nil, toError(err)
}
if clBuffer == nil {
return nil, ErrUnknown
}
return newMemObject(clBuffer, len(data)), nil
}
示例10: CreateSubBufferRegion
func (b *MemObject) CreateSubBufferRegion(flags MemFlag, origin int, size int) (*MemObject, error) {
var err C.cl_int
ci := C.cl_buffer_region{
origin: C.size_t(origin),
size: C.size_t(size),
}
clBuffer := C.clCreateSubBuffer(b.clMem, C.cl_mem_flags(flags),
C.CL_BUFFER_CREATE_TYPE_REGION, unsafe.Pointer(&ci), &err)
if err != C.CL_SUCCESS {
return nil, toError(err)
}
if clBuffer == nil {
return nil, ErrUnknown
}
return newMemObject(clBuffer, size), nil
}
示例11: CreateImage
//////////////// Abstract Functions ////////////////
func (ctx *Context) CreateImage(flags MemFlag, imageFormat ImageFormat, imageDesc ImageDescription, data []byte) (*MemObject, error) {
format := imageFormat.toCl()
desc := imageDesc.toCl()
var dataPtr unsafe.Pointer
if data != nil {
dataPtr = unsafe.Pointer(&data[0])
}
var err C.cl_int
clBuffer := C.clCreateImage(ctx.clContext, C.cl_mem_flags(flags), &format, &desc, dataPtr, &err)
if err != C.CL_SUCCESS {
return nil, toError(err)
}
if clBuffer == nil {
return nil, ErrUnknown
}
return newMemObject(clBuffer, len(data)), nil
}
示例12: NewImage3D
func (c *Context) NewImage3D(flags MemoryFlags, format ImageFormat, width, height, depth, rowPitch, slicePitch uint32, data *byte) (*Image, error) {
var c_buffer C.cl_mem
var err C.cl_int
c_format := &C.cl_image_format{
image_channel_order: C.cl_channel_order(format.ChannelOrder),
image_channel_data_type: C.cl_channel_type(format.ChannelDataType)}
if c_buffer = C.clCreateImage3D(c.id, C.cl_mem_flags(flags), c_format, C.size_t(width), C.size_t(height), C.size_t(depth), C.size_t(rowPitch), C.size_t(slicePitch), unsafe.Pointer(data), &err); err != C.CL_SUCCESS {
return nil, Cl_error(err)
}
image := &Image{id: c_buffer, format: format, properties: make(map[ImageProperty]Size)}
runtime.SetFinalizer(image, (*Image).release)
return image, nil
}
示例13: NewImage3D
func (c *Context) NewImage3D(flags MemFlags, order ChannelOrder, dataType ChannelType, width, height, depth, rowPitch, slicePitch uint32, data *byte) (*Image, error) {
var c_buffer C.cl_mem
var err C.cl_int
format := new(C.cl_image_format)
format.image_channel_order = C.cl_channel_order(order)
format.image_channel_data_type = C.cl_channel_type(dataType)
if c_buffer = C.clCreateImage3D(c.id, C.cl_mem_flags(flags), format, C.size_t(width), C.size_t(height), C.size_t(depth), C.size_t(rowPitch), C.size_t(slicePitch), unsafe.Pointer(data), &err); err != C.CL_SUCCESS {
return nil, Cl_error(err)
}
image := &Image{id: c_buffer, w: width, h: height, d: depth, hostptr: data}
runtime.SetFinalizer(image, (*Image).release)
return image, nil
}
示例14: CLCreateBuffer
func CLCreateBuffer(context CL_context,
flags CL_mem_flags,
size CL_size_t,
host_ptr unsafe.Pointer,
errcode_ret *CL_int) CL_mem {
var c_errcode_ret C.cl_int
var c_memobj C.cl_mem
c_memobj = C.clCreateBuffer(context.cl_context,
C.cl_mem_flags(flags),
C.size_t(size),
host_ptr,
&c_errcode_ret)
if errcode_ret != nil {
*errcode_ret = CL_int(c_errcode_ret)
}
return CL_mem{c_memobj}
}
示例15: CLCreateSubBuffer
func CLCreateSubBuffer(buffer CL_mem,
flags CL_mem_flags,
buffer_create_type CL_buffer_create_type,
buffer_create_info unsafe.Pointer,
errcode_ret *CL_int) CL_mem {
var c_errcode_ret C.cl_int
var c_memobj C.cl_mem
c_memobj = C.clCreateSubBuffer(buffer.cl_mem,
C.cl_mem_flags(flags),
C.cl_buffer_create_type(buffer_create_type),
buffer_create_info,
&c_errcode_ret)
if errcode_ret != nil {
*errcode_ret = CL_int(c_errcode_ret)
}
return CL_mem{c_memobj}
}