Module: Ikra::Configuration
- Defined in:
- lib/config/configuration.rb,
lib/config/os_configuration.rb
Constant Summary collapse
- JOB_REORDERING =
true
- SUPPORTED_OS =
[:linux, :macosx]
- ATTEMPT_AUTO_CONFIG =
true
- @@expect_file_name =
"last_generated"
Class Attribute Summary collapse
-
.auto_config ⇒ Object
Returns the value of attribute auto_config.
-
.cuda_manual_common_include ⇒ Object
Returns the value of attribute cuda_manual_common_include.
-
.cuda_manual_cupti_include ⇒ Object
Returns the value of attribute cuda_manual_cupti_include.
-
.cuda_manual_nvcc ⇒ Object
Returns the value of attribute cuda_manual_nvcc.
Class Method Summary collapse
- .codegen_expect_file_name ⇒ Object
- .codegen_expect_file_name=(value) ⇒ Object
- .codegen_expect_file_name_for(file_name) ⇒ Object
- .is_initialized? ⇒ Boolean
- .log_file_name_for(test_case_name) ⇒ Object
- .nvcc_invocation_string(in_file, out_file) ⇒ Object
- .operating_system ⇒ Object
- .reinitialize! ⇒ Object
- .reset_state ⇒ Object
- .resource_file_name(file_name) ⇒ Object
- .so_suffix ⇒ Object
Class Attribute Details
.auto_config ⇒ Object
Returns the value of attribute auto_config.
22 23 24 |
# File 'lib/config/os_configuration.rb', line 22 def auto_config @auto_config end |
.cuda_manual_common_include ⇒ Object
Returns the value of attribute cuda_manual_common_include.
20 21 22 |
# File 'lib/config/os_configuration.rb', line 20 def cuda_manual_common_include @cuda_manual_common_include end |
.cuda_manual_cupti_include ⇒ Object
Returns the value of attribute cuda_manual_cupti_include.
21 22 23 |
# File 'lib/config/os_configuration.rb', line 21 def cuda_manual_cupti_include @cuda_manual_cupti_include end |
.cuda_manual_nvcc ⇒ Object
Returns the value of attribute cuda_manual_nvcc.
19 20 21 |
# File 'lib/config/os_configuration.rb', line 19 def cuda_manual_nvcc @cuda_manual_nvcc end |
Class Method Details
.codegen_expect_file_name ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/config/configuration.rb', line 26 def self.codegen_expect_file_name if @@expect_file_name == nil # Do not generate expect file return nil end return codegen_expect_file_name_for(@@expect_file_name + ".cu") end |
.codegen_expect_file_name=(value) ⇒ Object
35 36 37 |
# File 'lib/config/configuration.rb', line 35 def self.codegen_expect_file_name=(value) @@expect_file_name = value end |
.codegen_expect_file_name_for(file_name) ⇒ Object
14 15 16 17 18 |
# File 'lib/config/configuration.rb', line 14 def self.codegen_expect_file_name_for(file_name) FileUtils.mkdir_p(File.("gen/codegen_expect", File.dirname(File.dirname(File.dirname(File.(__FILE__)))))) File.("gen/codegen_expect/#{file_name}", File.dirname(File.dirname(File.dirname(File.(__FILE__))))) end |
.is_initialized? ⇒ Boolean
24 25 26 |
# File 'lib/config/os_configuration.rb', line 24 def is_initialized? return @is_initialized end |
.log_file_name_for(test_case_name) ⇒ Object
20 21 22 23 24 |
# File 'lib/config/configuration.rb', line 20 def self.log_file_name_for(test_case_name) FileUtils.mkdir_p(File.("gen/log", File.dirname(File.dirname(File.dirname(File.(__FILE__)))))) File.("gen/log/#{test_case_name}.log", File.dirname(File.dirname(File.dirname(File.(__FILE__))))) end |
.nvcc_invocation_string(in_file, out_file) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/config/os_configuration.rb', line 70 def nvcc_invocation_string(in_file, out_file) if !is_initialized? reinitialize! end return "#{@cuda_nvcc} -o #{out_file} -I#{@cuda_common_include} -I#{@cuda_cupti_include} --shared -Xcompiler -fPIC -std=c++11 #{in_file} 2>&1" end |
.operating_system ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/config/os_configuration.rb', line 90 def # copied from: http://stackoverflow.com/questions/11784109/detecting-operating-systems-in-ruby host_os = RbConfig::CONFIG['host_os'] case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :macosx when /linux/ :linux when /solaris|bsd/ :unix else raise AssertionError.new("Unknown operating system") end end |
.reinitialize! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/config/os_configuration.rb', line 28 def reinitialize! if !SUPPORTED_OS.include?() raise AssertionError.new("Operating system not supported: #{}") end @cuda_nvcc = cuda_manual_nvcc @cuda_common_include = cuda_manual_common_include @cuda_cupti_include = cuda_manual_cupti_include # Auto configuration if auto_config Log.info("Attempting CUDA path auto configuration") nvcc_path = %x(which nvcc) if $?.exitstatus == 0 cuda_path = File.("../..", nvcc_path) @cuda_nvcc = File.("bin/nvcc", cuda_path) @cuda_common_include = File.("samples/common/inc", cuda_path) @cuda_cupti_include = File.("extras/CUPTI/include", cuda_path) else Log.warn("CUDA path auto configuration failed") end end # Check if nvcc is installed %x(#{@cuda_nvcc} 2>&1) if $?.exitstatus != 1 raise AssertionError.new("nvcc not installed") end if !File.directory?(@cuda_common_include) raise AssertionError.new("Directory does not exist: #{@cuda_common_include}. Check OS configuration!") end if !File.directory?(@cuda_cupti_include) raise AssertionError.new("Directory does not exist: #{@cuda_cupti_include}. Check OS configuration!") end @is_initialized = true end |
.reset_state ⇒ Object
39 40 41 |
# File 'lib/config/configuration.rb', line 39 def self.reset_state Symbolic::ArrayCommand.reset_unique_id end |
.resource_file_name(file_name) ⇒ Object
10 11 12 |
# File 'lib/config/configuration.rb', line 10 def self.resource_file_name(file_name) File.("resources/cuda/#{file_name}", File.dirname(File.dirname(File.(__FILE__)))) end |
.so_suffix ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/config/os_configuration.rb', line 78 def so_suffix if == :linux "so" elsif == :macosx "so" elsif == :windows "dll" else raise AssertionError.new("Operating system not supported") end end |