module ConvolutionGenerator

Constants

ARCHITECTURES
ARMCPUID_by_name
ARMarchitectures
AffinityProbe

@private

BP
Call
Dim
EXTENDED
EnergyProbe
FUNCCALLS
INSTRUCTIONS
LANGUAGES
MODELS
OP
Var
X86CPUID_by_name
X86architectures

Public Class Methods

boolean_state_accessor(state) click to toggle source

Generates setters and getters for the specified boolean state @param [Symbol] state @!macro [attach] boolean_state_accessor

@!method $1?
  @scope class
  @return the boolean evaluation of the *$1* state
@!parse state_accessor $1
# File lib/BOAST/Language/State.rb, line 61
  def self.boolean_state_accessor(state)
    state_accessor(state)
    s = <<EOF
  module_function

  def #{state}?
    @@#{state}
  end
EOF
    eval s
  end
default_state_getter(state, default, get_env_string=nil, env = state.upcase) click to toggle source

Generates an initializer for the specified state using default value or environment variable. Calls this initializer. @param [Symbol] state @param [Object] default default value @param [String] get_env_string if specified, an escaped string that can be evaluated. the envs variable can be used in the string to obtain what the corresponding environment variable was. Example: ‘“const_get(#{ envs })”’ @param [Symbol] env name of the corresponding environment variable @!macro [attach] default_state_getter

@!method get_default_$1
  @scope class
  @private
# File lib/BOAST/Language/State.rb, line 83
  def self.default_state_getter(state, default, get_env_string=nil, env = state.upcase)
    envs = "ENV['#{env}']"
    s = <<EOF
  module_function

  def get_default_#{state}
    #{state} = @@boast_config[#{state.inspect}]
    #{state} = #{default.inspect} unless #{state}
    #{state} = #{get_env_string ? eval( "#{get_env_string}" ) : "YAML::load(#{envs})" } if #{envs}
    return #{state}
  end

  @@#{state} = get_default_#{state}
EOF
    eval s
  end
generic_trigonometric_operator_generator( name ) click to toggle source
# File lib/BOAST/Language/HighLevelOperators.rb, line 138
  def self.generic_trigonometric_operator_generator( name )
    eval <<EOF
  class #{name.capitalize} < TrigonometricOperator
    extend Functor

    def get_intrinsic_symbol
      return :#{name.upcase}
    end

    def get_name
      return { C => "#{name}", CUDA => "#{name}", CL => "#{name}", FORTRAN => "#{name}" }
    end

  end

EOF
  end
included(base) click to toggle source
# File lib/BOAST/Language/State.rb, line 6
def self.included(base)
  EXTENDED.each { |m|
    base.send(:include, m)
  }
end
open(a) click to toggle source

@deprecated

# File lib/BOAST/Language/Print.rb, line 10
def self.open(a)
  opn(a)
end
print(a, *args) click to toggle source

@deprecated

state_accessor(state) click to toggle source

Generates setters and getters for the specified state @param [Symbol] state @!macro [attach] state_accessor

@!method $1
  @scope class
  @return the BOAST *$1* state
@!method $1=( val )
  @scope class
  Sets *$1* state to a new value
  @param val the new value of *$1* state
  @return the new +$1+ state
@!method get_$1
  @scope class
  @return the *$1* state
@!method set_$1( val )
  @scope class
  Sets *$1* state to a new value
  @param val the new value of *$1* state
  @return the new *$1* state
# File lib/BOAST/Language/State.rb, line 31
  def self.state_accessor(state)
    s = <<EOF
  module_function

  def #{state}=(val)
    @@#{state} = val
  end

  def #{state}
    @@#{state}
  end

  def set_#{state}(val)
    @@#{state} = val
  end

  def get_#{state}
    @@#{state}
  end
EOF
    eval s
  end

Public Instance Methods

annotate_number(name) click to toggle source

Returns an annotation number for the given name. The number is incremented for a given name is incremented each time this name is called

# File lib/BOAST/Language/Algorithm.rb, line 134
def annotate_number(name)
  num = @@annotate_numbers[name]
  @@annotate_numbers[name] = num + 1
  return num
end
assert_boast_config_dir() click to toggle source
# File lib/BOAST/Language/Config.rb, line 23
def assert_boast_config_dir
  home_config_dir = ENV["XDG_CONFIG_HOME"]
  home_config_dir = "#{Dir.home}/.config" unless home_config_dir
  Dir.mkdir( home_config_dir ) unless File::exist?( home_config_dir )
  return nil unless File::directory?(home_config_dir)
  boast_config_dir = "#{home_config_dir}/BOAST"
  Dir.mkdir( boast_config_dir ) unless File::exist?( boast_config_dir )
  return nil unless File::directory?(boast_config_dir)
  return boast_config_dir
end
close(a) click to toggle source

One of BOAST keywords: closes a BOAST ControlStructure or Procedure. Calls the close method of the given object. @param a the BOAST object to close

# File lib/BOAST/Language/Algorithm.rb, line 191
def close(a)
  a.close
end
decl(*list) click to toggle source

One of BOAST keywords: declares BOAST Variables and Procedures. Calls the decl method of each given objects. @param list a list of parameters do declare

# File lib/BOAST/Language/Algorithm.rb, line 175
def decl(*list)
  list.each { |d|
    d.decl
  }
end
decrement_indent_level(increment = get_indent_increment) click to toggle source

Decrements the indent level @param [Integer] increment number of space to remove

# File lib/BOAST/Language/Algorithm.rb, line 123
def decrement_indent_level(increment = get_indent_increment)
  set_indent_level( get_indent_level - increment )
end
get_architecture_name() click to toggle source

Returns the symbol corresponding to the active architecture

# File lib/BOAST/Language/Algorithm.rb, line 60
def get_architecture_name
  return ARCHITECTURES[architecture]
end
get_compiler_options() click to toggle source
# File lib/BOAST/Runtime/Config.rb, line 110
def get_compiler_options
  return @@compiler_default_options.clone
end
get_default_architecture() click to toggle source

@private

# File lib/BOAST/Language/Config.rb, line 162
def get_default_architecture
  architecture = nil
  begin
    env = nil
    if ENV["ARCHITECTURE"] then
      env = ENV["ARCHITECTURE"]
    elsif ENV["ARCH"] then
      env = ENV["ARCH"]
    end
    raise "Error" if env and not ARCHITECTURES.include?(env)
    architecture = const_get(env) if env
  rescue
    raise "'#{env}' is not a valid value for ARCH or ARCHITECTURE!"
  end
  return architecture if architecture
  return ARM if YAML::load( OS.report )["host_cpu"].match(/arm|aarch64/)
  return X86
end
get_lang_name() click to toggle source

Returns the symbol corresponding to the active language

# File lib/BOAST/Language/Algorithm.rb, line 65
def get_lang_name
  return LANGUAGES[lang]
end
get_openmp_flags() click to toggle source
# File lib/BOAST/Runtime/Config.rb, line 106
def get_openmp_flags
  return @@openmp_default_flags.clone
end
get_run_config() click to toggle source
# File lib/BOAST/Runtime/Config.rb, line 133
def get_run_config
  return @@run_config.clone
end
increment_indent_level(increment = get_indent_increment) click to toggle source

Increments the indent level @param [Integer] increment number of space to add

# File lib/BOAST/Language/Algorithm.rb, line 117
def increment_indent_level(increment = get_indent_increment)
  set_indent_level( get_indent_level + increment )
end
indent() click to toggle source

Returns a string with as many space as the indent level.

# File lib/BOAST/Language/Algorithm.rb, line 128
def indent
   return " "*get_indent_level
end
model=(val) click to toggle source
# File lib/BOAST/Language/Config.rb, line 156
def model=(val)
  set_model_old(val)
  Intrinsics::generate_conversions
end
opn(a) click to toggle source

One of BOAST keywords: opens a BOAST ControlStructure or Procedure. Calls the open method of the given object. @param a the BOAST object to open

# File lib/BOAST/Language/Algorithm.rb, line 184
def opn(a)
  a.open
end
pop_env(*vars) click to toggle source

Pops the specified states values @param vars a list of state symbols

# File lib/BOAST/Language/Algorithm.rb, line 106
def pop_env(*vars)
  vars.each { |key|
    raise "Unknown module variable #{key}!" unless @@env.has_key?(key)
    ret = @@env[key].pop
    raise "No stored value for #{key}!" if ret.nil?
    BOAST::send("set_#{key}", ret)
  }
end
pr(a, *args, &block) click to toggle source

One of BOAST keywords: prints BOAST objects. Annotates the given object. Calls the given object pr method with the optional arguments. @param a a BOAST Expression, ControlStructure or Procedure @param args an optional list of parameters

# File lib/BOAST/Language/Algorithm.rb, line 167
def pr(a, *args, &block)
  pr_annotate(a) if annotate?
  a.pr(*args, &block)
end
pr_annotate(a) click to toggle source

Annotates an Object by inlining a YAML structure in a comment. If object’s class is part of the annotate list an indepth version of the annotation will be generated. @param [Object] a object to annotate

# File lib/BOAST/Language/Algorithm.rb, line 149
def pr_annotate(a)
  name = a.class.name.gsub("BOAST::","")
  if annotate_list.include?(name) then
    description = nil
    if a.is_a?(Annotation) and a.annotate_indepth?(0) then
      description = a.annotation(0)
    end
    annotation = { "#{name}#{annotate_number(name)}" => description }
    Comment(YAML::dump(annotation)).pr
  end
end
push_env(vars, &block) click to toggle source

Updates states and stores their value in a stack for later retrieval @overload push_env( vars ) @overload push_env( vars, &block ) @param [Hash] vars contains state symbols and values pairs @yield states will be popped after the given block is called

# File lib/BOAST/Language/Algorithm.rb, line 81
def push_env(vars, &block)
  keys = []
  vars.each { |key, value|
    var = nil
    begin
      var = BOAST::send("get_#{key}")
    rescue
      BOAST::pop_env(*keys)
      raise "Unknown module variable #{key}!"
    end
    @@env[key].push(var)
    BOAST::send("set_#{key}", value)
    keys.push(key)
  }
  if block then
    begin
      block.call
    ensure
      BOAST::pop_env(*vars.keys)
    end
  end
end
read_boast_compiler_config() click to toggle source
# File lib/BOAST/Runtime/Config.rb, line 75
def read_boast_compiler_config
  boast_config_dir = assert_boast_config_dir
  return unless boast_config_dir
  compiler_options_file = "#{boast_config_dir}/compiler_options"
  if File::exist?( compiler_options_file ) then
    File::open( compiler_options_file, "r" ) { |f|
      @@compiler_default_options.update( YAML::load( f.read ) )
    }
  else
    File::open( compiler_options_file, "w" ) { |f|
      f.write YAML::dump( @@compiler_default_options )
    }
  end
  openmp_flags_file = "#{boast_config_dir}/openmp_flags"
  if File::exist?( openmp_flags_file ) then
    File::open( openmp_flags_file, "r" ) { |f|
      @@openmp_default_flags.update( YAML::load( f.read ) )
    }
  else
    File::open( openmp_flags_file, "w" ) { |f|
      f.write YAML::dump( @@openmp_default_flags )
    }
  end
  @@compiler_default_options.each_key { |k|
    @@compiler_default_options[k] = ENV[k.to_s] if ENV[k.to_s]
  }
  @@compiler_default_options[:LD] = ENV["LD"] if ENV["LD"]
end
read_boast_config() click to toggle source
# File lib/BOAST/Language/Config.rb, line 34
def read_boast_config
  boast_config_dir = assert_boast_config_dir
  return unless boast_config_dir
  boast_config_file = "#{boast_config_dir}/config"
  if File::exist?( boast_config_file ) then
    File::open( boast_config_file, "r" ) { |f|
      @@boast_config.update( YAML::load( f.read ) )
    }
  else
    File::open( boast_config_file, "w" ) { |f|
      f.write YAML::dump( @@boast_config )
    }
  end
end
read_boast_run_config() click to toggle source
# File lib/BOAST/Runtime/Config.rb, line 114
def read_boast_run_config
  boast_config_dir = assert_boast_config_dir
  run_config_file = "#{boast_config_dir}/run_config"
  if File::exist?( run_config_file ) then
    File::open( run_config_file, "r" ) { |f|
      @@run_config.update( YAML::load( f.read ) )
    }
  else
    File::open( run_config_file, "w" ) { |f|
      f.write YAML::dump( @@run_config )
    }
  end
  @@run_options.each { |o|
    @@run_config[o] = YAML::load(ENV[o.to_s]) if ENV[o.to_s]
  }
end
register_funccall(name, options = {}) click to toggle source
# File lib/BOAST/Language/Parens.rb, line 7
  def register_funccall(name, options = {})
    sym = name.to_sym
    ret = options[:return] ? options[:return] : options[:returns]
    FUNCCALLS[sym] = {}
    FUNCCALLS[sym][:parameters] = options[:parameters]
    FUNCCALLS[sym][:return] = ret
    s =<<EOF
    def self.#{name}(*args)
      return FuncCall(#{sym.inspect}, *args#{ ret ? ", return: FUNCCALLS[#{sym.inspect}][:return]" : ""})
    end
EOF
    eval s
  end
reset_annotate_numbers() click to toggle source

Resets the annotate_numbers to an empty Hash

# File lib/BOAST/Language/Algorithm.rb, line 141
def reset_annotate_numbers
  @@annotate_numbers = Hash::new { |h,k| h[k] = 0 }
end
set_model(val) click to toggle source
# File lib/BOAST/Language/Config.rb, line 150
def set_model(val)
  set_model_old(val)
  Intrinsics::generate_conversions
end
use_vla?() click to toggle source

@return the boolean evaluation of the use_vla state. false if lang is CL or CUDA.

# File lib/BOAST/Language/Config.rb, line 144
def use_vla?
  return false if [CL,CUDA].include?(lang)
  return use_vla_old?
end