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
090941a5
Commit
090941a5
authored
Feb 28, 2017
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable reading and writing buffers (blocking)
parent
bf5ebeab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
3 deletions
+59
-3
README.md
README.md
+2
-2
commandqueue.go
commandqueue.go
+26
-1
event.go
event.go
+31
-0
No files found.
README.md
View file @
090941a5
...
...
@@ -21,8 +21,8 @@ It is mainly developed and tested on Linux and with Intel and Nvidia GPUs. It sh
-
[
]
querying info
-
[
]
buffers
-
[
*
]
creating and releasing buffers
-
[
]
writing buffers
-
[
]
reading buffers
-
[
x
]
writing buffers (blocking only for now)
-
[
x
]
reading buffers (blocking only for now)
-
[
]
querying info
-
[
]
program objects
-
[
]
creating and releasing program objects
...
...
commandqueue.go
View file @
090941a5
...
...
@@ -8,7 +8,10 @@ package opencl
#endif
*/
import
"C"
import
"fmt"
import
(
"fmt"
"unsafe"
)
type
CommandQueue
struct
{
queue
C
.
cl_command_queue
...
...
@@ -61,3 +64,25 @@ func (q CommandQueue) Release() error {
}
return
nil
}
func
(
q
CommandQueue
)
EnqueueReadBuffer
(
memory
Memory
,
offset
uintptr
,
buffer
[]
byte
,
waitList
[]
Event
)
error
{
var
clEventsPtr
unsafe
.
Pointer
if
len
(
waitList
)
>
0
{
clEventsPtr
=
unsafe
.
Pointer
(
&
asCLEventList
(
waitList
)[
0
])
}
if
err
:=
C
.
clEnqueueReadBuffer
(
q
.
queue
,
memory
.
memory
,
C
.
CL_TRUE
,
C
.
size_t
(
offset
),
C
.
size_t
(
len
(
buffer
)),
unsafe
.
Pointer
(
&
buffer
[
0
]),
C
.
cl_uint
(
len
(
waitList
)),
clEventsPtr
,
nil
);
err
!=
C
.
CL_SUCCESS
{
return
fmt
.
Errorf
(
"failed to enqueue read: %d"
,
err
)
}
return
nil
}
func
(
q
CommandQueue
)
EnqueueWriteBuffer
(
memory
Memory
,
offset
uintptr
,
buffer
[]
byte
,
waitList
[]
Event
)
error
{
var
clEventsPtr
unsafe
.
Pointer
if
len
(
waitList
)
>
0
{
clEventsPtr
=
unsafe
.
Pointer
(
&
asCLEventList
(
waitList
)[
0
])
}
if
err
:=
C
.
clEnqueueWriteBuffer
(
q
.
queue
,
memory
.
memory
,
C
.
CL_TRUE
,
C
.
size_t
(
offset
),
C
.
size_t
(
len
(
buffer
)),
unsafe
.
Pointer
(
&
buffer
[
0
]),
C
.
cl_uint
(
len
(
waitList
)),
clEventsPtr
,
nil
);
err
!=
C
.
CL_SUCCESS
{
return
fmt
.
Errorf
(
"Failed to enqueue write: %d"
,
err
)
}
return
nil
}
event.go
0 → 100644
View file @
090941a5
package
opencl
/*
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
*/
import
"C"
import
"fmt"
type
Event
struct
{
event
C
.
cl_event
}
func
(
e
Event
)
Release
()
error
{
err
:=
C
.
clReleaseEvent
(
e
.
event
)
if
err
!=
C
.
CL_SUCCESS
{
return
fmt
.
Errorf
(
"failed to release event: %d"
,
err
)
}
return
nil
}
func
asCLEventList
(
events
[]
Event
)
[]
C
.
cl_event
{
result
:=
make
([]
C
.
cl_event
,
len
(
events
))
for
i
,
e
:=
range
events
{
result
[
i
]
=
e
.
event
}
return
result
}
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