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
0d8be358
Commit
0d8be358
authored
Feb 28, 2017
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable creating and releasing command queues
parent
a248256f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
+47
-2
README.md
README.md
+1
-1
commandqueue.go
commandqueue.go
+36
-0
context.go
context.go
+10
-1
No files found.
README.md
View file @
0d8be358
...
...
@@ -17,7 +17,7 @@ It is mainly developed and tested on Linux and with Intel and Nvidia GPUs. It sh
-
[
x
]
creating and releasing contexts
-
[
]
querying info
-
[
]
command queues
-
[
]
creating and releasing command queues
-
[
x
]
creating and releasing command queues
-
[
]
querying info
-
[
]
buffers
-
[
]
creating and releasing buffers
...
...
commandqueue.go
View file @
0d8be358
...
...
@@ -10,6 +10,10 @@ package opencl
import
"C"
import
"fmt"
type
CommandQueue
struct
{
queue
C
.
cl_command_queue
}
type
CommandQueueProperties
struct
{
OutOfOrderExec
bool
Profiling
bool
...
...
@@ -22,6 +26,38 @@ func fromCLProperties(properties C.cl_command_queue_properties) CommandQueueProp
return
result
}
func
(
p
CommandQueueProperties
)
toCLProperties
()
C
.
cl_command_queue_properties
{
var
result
C
.
cl_command_queue_properties
if
p
.
OutOfOrderExec
{
result
|=
C
.
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
}
if
p
.
Profiling
{
result
|=
C
.
CL_QUEUE_PROFILING_ENABLE
}
return
result
}
func
(
p
CommandQueueProperties
)
String
()
string
{
return
fmt
.
Sprintf
(
"QueueProperties{OutOfOrderExec: %t, Profiling: %t}"
,
p
.
OutOfOrderExec
,
p
.
Profiling
)
}
func
createCommandQueue
(
context
Context
,
device
Device
,
properties
*
CommandQueueProperties
)
(
*
CommandQueue
,
error
)
{
var
clProperties
C
.
cl_command_queue_properties
if
properties
!=
nil
{
clProperties
=
properties
.
toCLProperties
()
}
var
err
C
.
cl_int
queue
:=
C
.
clCreateCommandQueue
(
context
.
context
,
device
.
id
,
clProperties
,
&
err
)
if
err
!=
C
.
CL_SUCCESS
{
return
nil
,
fmt
.
Errorf
(
"failed to create command queue: %d"
,
err
)
}
return
&
CommandQueue
{
queue
},
nil
}
func
(
q
CommandQueue
)
Release
()
error
{
err
:=
C
.
clReleaseCommandQueue
(
q
.
queue
)
if
err
!=
C
.
CL_SUCCESS
{
return
fmt
.
Errorf
(
"falied to release command queue: %d"
,
err
)
}
return
nil
}
context.go
View file @
0d8be358
...
...
@@ -19,6 +19,7 @@ type Context struct {
context
C
.
cl_context
callback
func
(
string
,
unsafe
.
Pointer
,
uintptr
,
interface
{})
userdata
interface
{}
devices
[]
*
Device
}
type
ContextProperties
struct
{
...
...
@@ -31,7 +32,7 @@ func contextCallback(errinfo *C.char, private_info unsafe.Pointer, cb C.size_t,
}
func
CreateContext
(
properties
*
ContextProperties
,
devices
[]
*
Device
,
notify
func
(
string
,
unsafe
.
Pointer
,
uintptr
,
interface
{}),
userdata
interface
{})
(
*
Context
,
error
)
{
context
:=
Context
{
nil
,
notify
,
userdata
}
context
:=
Context
{
nil
,
notify
,
userdata
,
devices
}
ids
:=
make
([]
C
.
cl_device_id
,
len
(
devices
))
for
i
,
d
:=
range
devices
{
...
...
@@ -60,3 +61,11 @@ func (c Context) Release() error {
}
return
nil
}
func
(
c
Context
)
Devices
()
[]
*
Device
{
return
c
.
devices
}
func
(
c
Context
)
CreateCommandQueue
(
device
Device
,
properties
*
CommandQueueProperties
)
(
*
CommandQueue
,
error
)
{
return
createCommandQueue
(
c
,
device
,
properties
)
}
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