ffi-opencl 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +42 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/examples/capabilities.rb +30 -0
- data/ffi-opencl.gemspec +65 -0
- data/interfaces/cl.h +866 -0
- data/interfaces/cl.i +45 -0
- data/interfaces/cl_gl.h +227 -0
- data/interfaces/cl_platform.h +262 -0
- data/lib/ffi-opencl/cl.rb +366 -0
- data/lib/ffi-opencl/platform.rb +10 -0
- data/lib/ffi-opencl.rb +12 -0
- data/spec/ffi-opencl_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- data/tasks/generator.rake +11 -0
- data/test/ffi-opencl_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +88 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Martin Hess
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= ffi-opencl
|
2
|
+
|
3
|
+
This is an automatically generated ffi to OpenCL. There are no rubyisms to make the OpenCL API easier to use.
|
4
|
+
|
5
|
+
== Copyright
|
6
|
+
|
7
|
+
Copyright (c) 2009 Martin Hess. See LICENSE for details.
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
[sudo] gem install ffi-opencl --source http://gems.github.com
|
12
|
+
|
13
|
+
Or you can permanently add github to your gemservers with:
|
14
|
+
|
15
|
+
gem sources -a http://gems.github.com
|
16
|
+
[sudo] gem install ffi-opencl
|
17
|
+
|
18
|
+
=== Non Ruby dependencies
|
19
|
+
|
20
|
+
You need these to use the gem:
|
21
|
+
|
22
|
+
* libffi
|
23
|
+
* OpenCL Driver
|
24
|
+
|
25
|
+
== Gem development
|
26
|
+
|
27
|
+
You need this non-ruby executable if you want to work on the gem:
|
28
|
+
|
29
|
+
* swig
|
30
|
+
|
31
|
+
On a Mac this can be installed with:
|
32
|
+
|
33
|
+
sudo port install libffi swig
|
34
|
+
|
35
|
+
Additionally, you will need the ruby gem:
|
36
|
+
|
37
|
+
* ffi-swig-generator
|
38
|
+
|
39
|
+
== TODO
|
40
|
+
|
41
|
+
* Test cases to help verify that it works correctly on different OSs and CPU architectures
|
42
|
+
* More and better examples
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ffi-opencl"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "martinhes@mac.com"
|
10
|
+
gem.homepage = "http://github.com/hessml/ffi-opencl"
|
11
|
+
gem.authors = ["Martin Hess"]
|
12
|
+
gem.rubyforge_project = "ffi-opencl"
|
13
|
+
gem.add_dependency('ffi', '>= 0.3.0')
|
14
|
+
gem.requirements << 'libffi'
|
15
|
+
gem.requirements << 'swig'
|
16
|
+
gem.requirements << 'opencl 1.0 driver'
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
|
20
|
+
Jeweler::RubyforgeTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/rake/spectask'
|
26
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
require 'rake/rdoctask'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
if File.exist?('VERSION.yml')
|
43
|
+
config = YAML.load(File.read('VERSION.yml'))
|
44
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
45
|
+
else
|
46
|
+
version = ""
|
47
|
+
end
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "ffi-opencl #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
54
|
+
|
55
|
+
# Load the other rake files in the tasks folder
|
56
|
+
require 'fileutils'
|
57
|
+
require 'find'
|
58
|
+
begin
|
59
|
+
tasks_dir = File.join(File.expand_path(File.dirname(__FILE__)), "/tasks")
|
60
|
+
rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
|
61
|
+
import(*rakefiles)
|
62
|
+
rescue
|
63
|
+
puts "Problem importing tasks/*.rake"
|
64
|
+
end
|
65
|
+
|
66
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$: << "../lib"
|
2
|
+
require 'ffi-opencl'
|
3
|
+
|
4
|
+
MAX_PLATFORM_IDS = 100
|
5
|
+
|
6
|
+
platform_id_ptr = FFI::MemoryPointer.new(:pointer, MAX_PLATFORM_IDS)
|
7
|
+
num_platform_ptr = FFI::MemoryPointer.new :uint
|
8
|
+
|
9
|
+
err = CL.clGetPlatformIDs(MAX_PLATFORM_IDS, platform_id_ptr, num_platform_ptr)
|
10
|
+
raise "clGetPlatformIDs failed: #{err}" unless err == CL::CL_SUCCESS
|
11
|
+
|
12
|
+
num_platform = num_platform_ptr.read_int
|
13
|
+
platform_ids = platform_id_ptr.read_array_of_int(num_platform)
|
14
|
+
|
15
|
+
a = platform_id_ptr.read_array_of_pointer(num_platform)
|
16
|
+
puts "There is/are #{num_platform} platforms"
|
17
|
+
a.each do |id|
|
18
|
+
|
19
|
+
MAX_PLATFORM_PROFILE_STRING = 256
|
20
|
+
platform_profile_ptr = FFI::MemoryPointer.new(:pointer, MAX_PLATFORM_PROFILE_STRING)
|
21
|
+
platform_profile_size_ptr = FFI::MemoryPointer.new :uint
|
22
|
+
|
23
|
+
err = CL.clGetPlatformInfo(id, CL::CL_PLATFORM_PROFILE, MAX_PLATFORM_PROFILE_STRING, platform_profile_ptr, platform_profile_size_ptr)
|
24
|
+
raise "clGetPlatformInfo failed: #{err}" unless err == CL::CL_SUCCESS
|
25
|
+
|
26
|
+
n = platform_profile_size_ptr.read_int
|
27
|
+
s = platform_profile_ptr.read_string(n)
|
28
|
+
|
29
|
+
puts s
|
30
|
+
end
|
data/ffi-opencl.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ffi-opencl}
|
5
|
+
s.version = "0.1.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Martin Hess"]
|
9
|
+
s.date = %q{2009-06-25}
|
10
|
+
s.email = %q{martinhes@mac.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".document",
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"examples/capabilities.rb",
|
23
|
+
"ffi-opencl.gemspec",
|
24
|
+
"interfaces/cl.h",
|
25
|
+
"interfaces/cl.i",
|
26
|
+
"interfaces/cl_gl.h",
|
27
|
+
"interfaces/cl_platform.h",
|
28
|
+
"lib/ffi-opencl.rb",
|
29
|
+
"lib/ffi-opencl/cl.rb",
|
30
|
+
"lib/ffi-opencl/platform.rb",
|
31
|
+
"spec/ffi-opencl_spec.rb",
|
32
|
+
"spec/spec_helper.rb",
|
33
|
+
"tasks/generator.rake",
|
34
|
+
"test/ffi-opencl_test.rb",
|
35
|
+
"test/test_helper.rb"
|
36
|
+
]
|
37
|
+
s.has_rdoc = true
|
38
|
+
s.homepage = %q{http://github.com/hessml/ffi-opencl}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.requirements = ["libffi", "swig", "opencl 1.0 driver"]
|
42
|
+
s.rubyforge_project = %q{ffi-opencl}
|
43
|
+
s.rubygems_version = %q{1.3.1}
|
44
|
+
s.summary = %q{TODO}
|
45
|
+
s.test_files = [
|
46
|
+
"spec/ffi-opencl_spec.rb",
|
47
|
+
"spec/spec_helper.rb",
|
48
|
+
"test/ffi-opencl_test.rb",
|
49
|
+
"test/test_helper.rb",
|
50
|
+
"examples/capabilities.rb"
|
51
|
+
]
|
52
|
+
|
53
|
+
if s.respond_to? :specification_version then
|
54
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
|
+
s.specification_version = 2
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
58
|
+
s.add_runtime_dependency(%q<ffi>, [">= 0.3.0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<ffi>, [">= 0.3.0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<ffi>, [">= 0.3.0"])
|
64
|
+
end
|
65
|
+
end
|