Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
parallel_examples
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Christoph Gerum
parallel_examples
Commits
3ef76ba7
Commit
3ef76ba7
authored
Jun 03, 2013
by
Christoph Gerum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started opencl pi
parent
dac7eb52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
pi
opencl/pi
+0
-0
pi.c
opencl/pi.c
+56
-0
No files found.
opencl/pi
0 → 100755
View file @
3ef76ba7
File added
opencl/pi.c
0 → 100644
View file @
3ef76ba7
#include <CL/cl.h>
#include <stdio.h>
#include <stdlib.h>
char
*
pi_kernel_source
=
"
\n
"
\
"__kernel void pi(
\n
"
\
" __global float *buffer,
\n
"
\
" const unsigned int count)
\n
"
\
"{
\n
"
\
" int i = get_global_id(0);
\n
"
\
" if(i < count){
\n
"
\
" output[i] = input[i] * input[i];
\n
"
\
" }
\n
"
\
"}
\n
"
\
"
\n
"
;
int
main
(
int
argc
,
char
**
argv
){
cl_uint
platform_id_count
=
0
;
clGetPlatformIDs
(
0
,
0
,
&
platform_id_count
);
printf
(
"System has %d opencl Platforms
\n
"
,
platform_id_count
);
cl_platform_id
*
platform_ids
=
malloc
(
platform_id_count
*
sizeof
(
cl_platform_id
));
clGetPlatformIDs
(
platform_id_count
,
platform_ids
,
0
);
cl_uint
device_id_count
=
0
;
clGetDeviceIDs
(
platform_ids
[
0
],
CL_DEVICE_TYPE_ALL
,
0
,
0
,
&
device_id_count
);
cl_device_id
*
device_ids
=
malloc
(
device_id_count
*
sizeof
(
cl_device_id
));
clGetDeviceIDs
(
platform_ids
[
0
],
CL_DEVICE_TYPE_ALL
,
device_id_count
,
device_ids
,
0
);
cl_context
context
;
context
=
clCreateContext
(
0
,
1
,
device_ids
,
0
,
0
,
0
);
cl_command_queue
commands
;
commands
=
clCreateCommandQueue
(
context
,
device_ids
[
0
],
0
,
0
);
cl_program
program
;
program
=
clCreateProgramWithSource
(
context
,
1
,
(
const
char
**
)
&
pi_kernel_source
,
0
,
0
);
if
(
!
program
)
{
printf
(
"Error: Failed to create compute program!
\n
"
);
return
-
1
;
}
return
0
;
}
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