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
a248256f
Commit
a248256f
authored
Feb 28, 2017
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable creating and releasing contexts
parent
73372c6d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletion
+63
-1
README.md
README.md
+1
-1
context.go
context.go
+62
-0
No files found.
README.md
View file @
a248256f
...
...
@@ -14,7 +14,7 @@ It is mainly developed and tested on Linux and with Intel and Nvidia GPUs. It sh
-
[
x
]
querying info
-
[
]
subdevices (not planned for now)
-
[
]
context
-
[
]
creating and releasing contexts
-
[
x
]
creating and releasing contexts
-
[
]
querying info
-
[
]
command queues
-
[
]
creating and releasing command queues
...
...
context.go
0 → 100644
View file @
a248256f
package
opencl
/*
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
extern void contextCallback(char *, void *, size_t, void *);
*/
import
"C"
import
(
"fmt"
"unsafe"
)
type
Context
struct
{
context
C
.
cl_context
callback
func
(
string
,
unsafe
.
Pointer
,
uintptr
,
interface
{})
userdata
interface
{}
}
type
ContextProperties
struct
{
}
//export contextCallback
func
contextCallback
(
errinfo
*
C
.
char
,
private_info
unsafe
.
Pointer
,
cb
C
.
size_t
,
user_data
unsafe
.
Pointer
)
{
context
:=
*
(
*
Context
)(
user_data
)
context
.
callback
(
C
.
GoString
(
errinfo
),
private_info
,
uintptr
(
cb
),
context
.
userdata
)
}
func
CreateContext
(
properties
*
ContextProperties
,
devices
[]
*
Device
,
notify
func
(
string
,
unsafe
.
Pointer
,
uintptr
,
interface
{}),
userdata
interface
{})
(
*
Context
,
error
)
{
context
:=
Context
{
nil
,
notify
,
userdata
}
ids
:=
make
([]
C
.
cl_device_id
,
len
(
devices
))
for
i
,
d
:=
range
devices
{
ids
[
i
]
=
d
.
id
}
var
callback
*
[
0
]
byte
var
user
unsafe
.
Pointer
if
notify
!=
nil
{
callback
=
(
*
[
0
]
byte
)(
unsafe
.
Pointer
(
C
.
contextCallback
))
user
=
unsafe
.
Pointer
(
&
context
)
}
var
err
C
.
cl_int
context
.
context
=
C
.
clCreateContext
(
nil
,
C
.
cl_uint
(
len
(
ids
)),
&
ids
[
0
],
callback
,
user
,
&
err
)
if
err
!=
C
.
CL_SUCCESS
{
return
nil
,
fmt
.
Errorf
(
"Error creating context: %d"
,
err
)
}
return
&
context
,
nil
}
func
(
c
Context
)
Release
()
error
{
err
:=
C
.
clReleaseContext
(
c
.
context
)
if
err
!=
C
.
CL_SUCCESS
{
return
fmt
.
Errorf
(
"Error releasing context: %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