hessml-ffi-opencl 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
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.1
@@ -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
@@ -0,0 +1,61 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ffi-opencl}
5
+ s.version = "0.1.1"
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
+ ]
35
+ s.has_rdoc = true
36
+ s.homepage = %q{http://github.com/hessml/ffi-opencl}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.requirements = ["libffi", "swig", "opencl 1.0 driver"]
40
+ s.rubyforge_project = %q{ffi-opencl}
41
+ s.rubygems_version = %q{1.3.1}
42
+ s.summary = %q{TODO}
43
+ s.test_files = [
44
+ "spec/ffi-opencl_spec.rb",
45
+ "spec/spec_helper.rb",
46
+ "examples/capabilities.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 2
52
+
53
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<ffi>, [">= 0.3.0"])
55
+ else
56
+ s.add_dependency(%q<ffi>, [">= 0.3.0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<ffi>, [">= 0.3.0"])
60
+ end
61
+ end