Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
opencl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mastersthesis-philipp
opencl
Commits
bf5ebeab
Commit
bf5ebeab
authored
Feb 28, 2017
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable creating and releasing buffers
parent
0d8be358
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
1 deletion
+58
-1
README.md
README.md
+1
-1
context.go
context.go
+4
-0
memory.go
memory.go
+53
-0
No files found.
README.md
View file @
bf5ebeab
...
...
@@ -20,7 +20,7 @@ It is mainly developed and tested on Linux and with Intel and Nvidia GPUs. It sh
-
[
x
]
creating and releasing command queues
-
[
]
querying info
-
[
]
buffers
-
[
]
creating and releasing buffers
-
[
*
]
creating and releasing buffers
-
[
]
writing buffers
-
[
]
reading buffers
-
[
]
querying info
...
...
context.go
View file @
bf5ebeab
...
...
@@ -69,3 +69,7 @@ func (c Context) Devices() []*Device {
func
(
c
Context
)
CreateCommandQueue
(
device
Device
,
properties
*
CommandQueueProperties
)
(
*
CommandQueue
,
error
)
{
return
createCommandQueue
(
c
,
device
,
properties
)
}
func
(
c
Context
)
CreateBuffer
(
flags
MemoryFlags
,
size
uintptr
,
hostPtr
unsafe
.
Pointer
)
(
*
Memory
,
error
)
{
return
createBuffer
(
c
,
flags
,
size
,
hostPtr
)
}
memory.go
0 → 100644
View file @
bf5ebeab
package
opencl
/*
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
*/
import
"C"
import
(
"fmt"
"unsafe"
)
type
MemoryFlags
int
const
(
MemReadWrite
=
MemoryFlags
(
C
.
CL_MEM_READ_WRITE
)
MemWriteOnly
=
MemoryFlags
(
C
.
CL_MEM_WRITE_ONLY
)
MemReadOnly
=
MemoryFlags
(
C
.
CL_MEM_READ_ONLY
)
MemUseHostPtr
=
MemoryFlags
(
C
.
CL_MEM_USE_HOST_PTR
)
MemAllocHostPtr
=
MemoryFlags
(
C
.
CL_MEM_ALLOC_HOST_PTR
)
MemCopyHostPtr
=
MemoryFlags
(
C
.
CL_MEM_COPY_HOST_PTR
)
MemHostWriteOnly
=
MemoryFlags
(
C
.
CL_MEM_HOST_WRITE_ONLY
)
MemHostReadOnly
=
MemoryFlags
(
C
.
CL_MEM_READ_ONLY
)
MemHostNoAccess
=
MemoryFlags
(
C
.
CL_MEM_HOST_NO_ACCESS
)
)
func
(
f
MemoryFlags
)
asClFlags
()
C
.
cl_mem_flags
{
return
C
.
cl_mem_flags
(
f
)
}
type
Memory
struct
{
memory
C
.
cl_mem
}
func
createBuffer
(
context
Context
,
flags
MemoryFlags
,
size
uintptr
,
hostPtr
unsafe
.
Pointer
)
(
*
Memory
,
error
)
{
var
err
C
.
cl_int
memory
:=
C
.
clCreateBuffer
(
context
.
context
,
flags
.
asClFlags
(),
C
.
size_t
(
size
),
hostPtr
,
&
err
)
if
err
!=
C
.
CL_SUCCESS
{
return
nil
,
fmt
.
Errorf
(
"failed to create buffer: %d"
,
err
)
}
return
&
Memory
{
memory
},
nil
}
func
(
m
Memory
)
Release
()
error
{
err
:=
C
.
clReleaseMemObject
(
m
.
memory
)
if
err
!=
C
.
CL_SUCCESS
{
return
fmt
.
Errorf
(
"failed to release memory object: %d"
,
err
)
}
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment