<commit_before>module IntelPSE

export DomainIR, ParallelIR, AliasAnalysis, LD
export decompose, offload, set_debug_level, getenv
using CompilerTools.LambdaHandling

# MODE for offload
const TOPLEVEL=1
const PROXYONLY=3

# 0 = none
# 1 = host
# 2 = offload1
# 3 = offload2
# 4 = task
# 5 = threads
client_intel_pse_mode = 1
# true if use task graph, false if use old-style whole-function conversion.
client_intel_task_graph = false
import Base.show

if haskey(ENV,"INTEL_PSE_MODE")
  mode = ENV["INTEL_PSE_MODE"]
  if mode == 0 || mode == "none"
    client_intel_pse_mode = 0
  elseif mode == 1 || mode == "host"
    client_intel_pse_mode = 1
  elseif mode == 2 || mode == "offload1"
    client_intel_pse_mode = 2
  elseif mode == 3 || mode == "offload2"
    client_intel_pse_mode = 3
  elseif mode == 4 || mode == "task"
    client_intel_pse_mode = 4
  elseif mode == 5 || mode == "threads"
    client_intel_pse_mode = 5
  else
    println("Unknown INTEL_PSE_MODE = ", mode)
  end
end

# a hack to make offload function available to domain IR. The assumption is that this
# is neither a TOPLEVEL function for J2C, nor a PROXYONLY compilation.
_offload(func, sig) = offload(func, sig, 0)

type CallInfo
  func_sig                             # a tuple of (function, signature)
  could_be_global :: Set               # the set of indices of arguments to the function that are or could be global arrays
  array_parameters :: Dict{Int,Any}    # the set of indices of arguments to the function that are or could be array parameters to the caller
end

type FunctionInfo
  func_sig                             # a tuple of (function, signature)
  calls :: Array{CallInfo,1}
  array_params_set_or_aliased :: Set   # the indices of the parameters that are set or aliased
  can_parallelize :: Bool              # false if a global is written in this function
  recursive_parallelize :: Bool
  params
  locals
  types
end<commit_msg>Create a common function between old system and PSE package for getting the PSE mode so that benchmarks can use that rather than assume the flag is in Base.<commit_after>module IntelPSE

export DomainIR, ParallelIR, AliasAnalysis, LD
export decompose, offload, set_debug_level, getenv
using CompilerTools.LambdaHandling

# MODE for offload
const TOPLEVEL=1
const PROXYONLY=3

# 0 = none
# 1 = host
# 2 = offload1
# 3 = offload2
# 4 = task
# 5 = threads
client_intel_pse_mode = 1
# true if use task graph, false if use old-style whole-function conversion.
client_intel_task_graph = false
import Base.show

if haskey(ENV,"INTEL_PSE_MODE")
  mode = ENV["INTEL_PSE_MODE"]
  if mode == 0 || mode == "none"
    client_intel_pse_mode = 0
  elseif mode == 1 || mode == "host"
    client_intel_pse_mode = 1
  elseif mode == 2 || mode == "offload1"
    client_intel_pse_mode = 2
  elseif mode == 3 || mode == "offload2"
    client_intel_pse_mode = 3
  elseif mode == 4 || mode == "task"
    client_intel_pse_mode = 4
  elseif mode == 5 || mode == "threads"
    client_intel_pse_mode = 5
  else
    println("Unknown INTEL_PSE_MODE = ", mode)
  end
end

@doc """
Provide a way to access the mode variable so that we can change the implementation over time if we have to.
"""
function getIntelPseMode()
  return client_intel_pse_mode
end

# a hack to make offload function available to domain IR. The assumption is that this
# is neither a TOPLEVEL function for J2C, nor a PROXYONLY compilation.
_offload(func, sig) = offload(func, sig, 0)

type CallInfo
  func_sig                             # a tuple of (function, signature)
  could_be_global :: Set               # the set of indices of arguments to the function that are or could be global arrays
  array_parameters :: Dict{Int,Any}    # the set of indices of arguments to the function that are or could be array parameters to the caller
end

type FunctionInfo
  func_sig                             # a tuple of (function, signature)
  calls :: Array{CallInfo,1}
  array_params_set_or_aliased :: Set   # the indices of the parameters that are set or aliased
  can_parallelize :: Bool              # false if a global is written in this function
  recursive_parallelize :: Bool
  params
  locals
  types
end
{'fraction_non_alphanumeric': 0.07260963335729691, 'fraction_numerical': 0.013419602204648934, 'mean_word_length': 3.361546499477534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4177385', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1295, 'n_words': 494}