module Ikra::Configuration

Constants

ATTEMPT_AUTO_CONFIG
JOB_REORDERING
SUPPORTED_OS

Attributes

auto_config[RW]
cuda_manual_common_include[RW]
cuda_manual_cupti_include[RW]
cuda_manual_nvcc[RW]

Public Class Methods

codegen_expect_file_name() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/config/configuration.rb, line 14
def self.codegen_expect_file_name_for(file_name)
    FileUtils.mkdir_p(File.expand_path("gen/codegen_expect", File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))))
    
    File.expand_path("gen/codegen_expect/#{file_name}", File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))))
end
is_initialized?() click to toggle source
# File lib/config/os_configuration.rb, line 24
def is_initialized?
    return @is_initialized
end
log_file_name_for(test_case_name) click to toggle source
# File lib/config/configuration.rb, line 20
def self.log_file_name_for(test_case_name)
    FileUtils.mkdir_p(File.expand_path("gen/log", File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))))

    File.expand_path("gen/log/#{test_case_name}.log", File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))))
end
nvcc_invocation_string(in_file, out_file) click to toggle source
# 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() click to toggle source
# File lib/config/os_configuration.rb, line 90
def operating_system
    # 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!() click to toggle source
# File lib/config/os_configuration.rb, line 28
def reinitialize!
    if !SUPPORTED_OS.include?(operating_system)
        raise AssertionError.new("Operating system not supported: #{operating_system}")
    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.expand_path("../..", nvcc_path)
            @cuda_nvcc = File.expand_path("bin/nvcc", cuda_path)
            @cuda_common_include = File.expand_path("samples/common/inc", cuda_path)
            @cuda_cupti_include = File.expand_path("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() click to toggle source
# File lib/config/configuration.rb, line 39
def self.reset_state
    Symbolic::ArrayCommand.reset_unique_id
end
resource_file_name(file_name) click to toggle source
# File lib/config/configuration.rb, line 10
def self.resource_file_name(file_name)
    File.expand_path("resources/cuda/#{file_name}", File.dirname(File.dirname(File.expand_path(__FILE__))))
end
so_suffix() click to toggle source
# File lib/config/os_configuration.rb, line 78
def so_suffix
    if operating_system == :linux
        "so"
    elsif operating_system == :macosx
        "so"
    elsif operating_system == :windows
        "dll"
    else
        raise AssertionError.new("Operating system not supported")
    end
end