def target_compiler_is_prgenv(): compiler_val = chpl_compiler.get('target') # But for --llvm, look at the original target compiler if compiler_val == 'clang-included': compiler_val = chpl_compiler.get('target', llvm_mode="orig") isprgenv = compiler_is_prgenv(compiler_val) return isprgenv
def target_compiler_is_prgenv(bypass_llvm=True): compiler_val = chpl_compiler.get('target') # But for --llvm, look at the original target compiler if bypass_llvm: if compiler_val == 'clang-included': compiler_val = chpl_compiler.get('target', llvm_mode="orig") isprgenv = compiler_is_prgenv(compiler_val) return isprgenv
def get(): launcher_val = overrides.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith('cray-x') or chpl_platform.is_cross_compiling(): has_aprun = find_executable('aprun') has_slurm = find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm or platform_val == 'aarch64': launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) sys.stderr.write( 'Warning: Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.\n') elif platform_val == 'marenostrum': launcher_val = 'marenostrum' elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': if platform_val == 'pwr6': # our loadleveler launcher is not yet portable/stable/ # flexible enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' else: launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'lapi': # our loadleveler launcher is not yet portable/stable/flexible # enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def get(): gmp_val = overrides.get('CHPL_GMP') if not gmp_val: target_compiler = chpl_compiler.get('target') if target_compiler == 'cray-prgenv-cray': gmp_val = 'system' else: target_platform = chpl_platform.get('target') # Detect if gmp has been built for this configuration. third_party = get_chpl_third_party() uniq_cfg_path = get_uniq_cfg_path() gmp_subdir = os.path.join(third_party, 'gmp', 'install', uniq_cfg_path) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'bundled' elif target_platform.startswith('cray-x'): gmp_val = 'system' elif target_platform == 'aarch64': gmp_val = 'system' else: gmp_val = 'none' elif gmp_val == 'gmp': sys.stderr.write("Warning: CHPL_GMP=gmp is deprecated. " "Use CHPL_GMP=bundled instead.\n") gmp_val = 'bundled' return gmp_val
def adjust_cpu_for_compiler(cpu, flag, get_lcd): compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = flag == 'target' and target_compiler_is_prgenv() if isprgenv: cray_cpu = os.environ.get('CRAY_CPU_TARGET', 'none') if cpu and (cpu != 'none' and cpu != 'unknown' and cpu != cray_cpu): stderr.write("Warning: Setting the processor type through " "environment variables is not supported for " "cray-prgenv-*. Please use the appropriate craype-* " "module for your processor type.\n") cpu = cray_cpu if cpu == 'none': stderr.write("Warning: No craype-* processor type module was " "detected, please load the appropriate one if you want " "any specialization to occur.\n") if get_lcd: cpu = get_module_lcd_cpu(platform_val, cpu) if cpu == 'none': stderr.write("Warning: Could not detect the lowest common " "denominator processor type for this platform. " "You may be unable to use the Chapel compiler\n") return cpu elif 'pgi' in compiler_val: return 'none' elif 'cray' in compiler_val: return 'none' elif 'ibm' in compiler_val: return 'none' return cpu
def get(): comm_val = os.environ.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') # use ugni on cray-x* machines using the module and supported compiler # # Check that target arch is not knc. Don't use chpl_arch.get(), though, # since it already calls into this get() function. This check only # happens for X* systems using the Cray programming environment, so it # is safe to assume the relevant craype module will be used that sets # CRAY_CPU_TARGET. ugni_comp = ('cray-prgenv-gnu', 'cray-prgenv-intel', 'cray-prgenv-cray') if (platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ugni_comp and os.getenv('CRAY_CPU_TARGET', '') != 'knc'): comm_val = 'ugni' # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def get(): comm_val = os.environ.get("CHPL_COMM") if not comm_val: platform_val = chpl_platform.get("target") compiler_val = chpl_compiler.get("target") # use ugni on cray-x* machines using the module and supported compiler # # Check that target arch is not knc. Don't use chpl_arch.get(), though, # since it already calls into this get() function. This check only # happens for X* systems using the Cray programming environment, so it # is safe to assume the relevant craype module will be used that sets # CRAY_CPU_TARGET. if ( platform_val.startswith("cray-x") and utils.using_chapel_module() and compiler_val in ("cray-prgenv-gnu", "cray-prgenv-intel") and os.getenv("CRAY_CPU_TARGET", "") != "knc" ): comm_val = "ugni" # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith("cray-"): comm_val = "gasnet" else: comm_val = "none" return comm_val
def filter_compile_args(args): compiler = chpl_compiler.get('target') is_prgenv = compiler_utils.target_compiler_is_prgenv(bypass_llvm=True) ret = [ ] if compiler == 'llvm' and is_prgenv: # filter out compile arguments not starting with -D or -I n = len(args) i = 0 while i < n: s = args[i] if s.startswith('-D') or s.startswith('-I'): ret.append(s) if len(s) == 2 and i+1 < n: # if it was just -D or -I, add the next argument too i += 1 ret.append(args[i]) i += 1 return ret else: # otherwise, just return the args the way they were ret = args # subsequently, filter away a few gasnet flags we don't want # an alternative to this filtering would be to only grab # certain flags from the gasnet .pc file more_filtered = [ ] for arg in ret: if arg.startswith('-O') or arg == '-Winline': pass # leave out this flag else: more_filtered.append(arg) return more_filtered
def get(flag, map_to_compiler=False, get_lcd=False): cpu_tuple = collections.namedtuple('cpu_tuple', ['flag', 'cpu']) if not flag or flag == 'host': cpu = overrides.get('CHPL_HOST_CPU', '') elif flag == 'target': cpu = overrides.get('CHPL_TARGET_CPU', '') else: raise InvalidLocationError(flag) # fast path out for when the user has set arch=none if cpu == 'none' or (flag == 'host' and not cpu): return cpu_tuple('none', 'none') # Handle backwards compatability - CHPL_TARGET_ARCH might be # set instead of the currently preferred CHPL_TARGET_CPU. if not cpu: oldarch = None if not flag or flag == 'host': oldarch = overrides.get('CHPL_HOST_ARCH', '') elif flag == 'target': oldarch = overrides.get('CHPL_TARGET_ARCH', '') else: raise InvalidLocationError(flag) # If the oldarch indicates a CPU, use it if arch_for_cpu(oldarch, flag): cpu = oldarch # Adjust arch for compiler (not all compilers support all arch # settings; PrgEnv might override arch, etc) cpu = adjust_cpu_for_compiler (cpu, flag, get_lcd) # Now, if is not yet set, we should set the default. if not cpu: cpu = default_cpu(flag) verify_cpu(cpu, flag) compiler_val = chpl_compiler.get(flag) isprgenv = compiler_is_prgenv(compiler_val) if map_to_compiler and not isprgenv: # Map cpu to compiler argument # Don't do this for PrgEnv compiles since the compiler driver # handles specialization. version = get_compiler_version(compiler_val) cpu = argument_map.find(cpu, compiler_val, version) if cpu and cpu != 'none' and cpu != 'unknown': # x86 uses -march= where the others use -mcpu= if is_x86_variant(get_native_machine()): flag = 'arch' else: flag = 'cpu' else: flag = 'none' return cpu_tuple(flag or 'none', cpu or 'unknown')
def adjust_cpu_for_compiler(cpu, flag, get_lcd): compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = flag == 'target' and target_compiler_is_prgenv() if isprgenv: cray_cpu = os.environ.get('CRAY_CPU_TARGET', 'none') if cpu and (cpu != 'none' and cpu != 'unknown' and cpu != cray_cpu): stderr.write("Warning: Setting the processor type through " "environment variables is not supported for " "cray-prgenv-*. Please use the appropriate craype-* " "module for your processor type.\n") cpu = cray_cpu if cpu == 'none': stderr.write( "Warning: No craype-* processor type module was " "detected, please load the appropriate one if you want " "any specialization to occur.\n") if get_lcd: cpu = get_module_lcd_cpu(platform_val, cpu) if cpu == 'none': stderr.write("Warning: Could not detect the lowest common " "denominator processor type for this platform. " "You may be unable to use the Chapel compiler\n") return cpu elif 'pgi' in compiler_val: return 'none' elif 'cray' in compiler_val: return 'none' elif 'ibm' in compiler_val: return 'none' return cpu
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: arch_val = chpl_arch.get('target', get_lcd=True) platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') comm_val = chpl_comm.get() # use muxed on cray-x* machines using the module and supported compiler if (comm_val == 'ugni' and platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ('cray-prgenv-gnu', 'cray-prgenv-intel') and arch_val != 'knc'): tasks_val = 'muxed' elif (arch_val == 'knc' or platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or compiler_val == 'pgi' or compiler_val == 'cray-prgenv-pgi' or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): launcher_val = os.environ.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith('cray-x'): has_aprun = utils.find_executable('aprun') has_slurm = utils.find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm: launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) sys.stderr.write( 'Warning: Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.\n') elif platform_val == 'marenostrum': launcher_val = 'marenostrum' elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': if platform_val == 'pwr6': # our loadleveler launcher is not yet portable/stable/ # flexible enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' else: launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'lapi': # our loadleveler launcher is not yet portable/stable/flexible # enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def default_uniq_cfg_path(): arch_val = chpl_arch.get('target', map_to_compiler=True, get_lcd=using_chapel_module()).arch return '{0}-{1}-{2}-{3}'.format(chpl_platform.get('target'), chpl_compiler.get('target'), arch_val, chpl_lib_pic.get())
def get_link_args(): link_args = third_party_utils.default_get_link_args( "qthread", ucp=get_uniq_cfg_path(), libs=["libqthread_chpl.la", "-lchpl", "libqthread.la"] ) compiler_val = chpl_compiler.get("target") if compiler_val == "cray-prgenv-cray" or (compiler_is_prgenv(compiler_val) and chpl_llvm.get() != "none"): link_args.append("-lrt") return link_args
def target_compiler_is_prgenv(bypass_llvm=True): compiler_val = chpl_compiler.get('target') # But for CHPL_TARGET_COMPILER=llvm, look at the original target compiler if bypass_llvm: if compiler_val == 'llvm': compiler_val = chpl_compiler.get_prgenv_compiler() isprgenv = chpl_compiler.compiler_is_prgenv(compiler_val) return isprgenv
def get_uniq_cfg_path(flag): # uses host/ or target/ before the usual subdir # host subdir computed here since third_party_utils doesn't have a default if flag == 'host': host_bin_subdir = chpl_bin_subdir.get('host') host_compiler = chpl_compiler.get('host') host_info = '{0}-{1}'.format(host_bin_subdir, host_compiler) return os.path.join('host', host_info) else: # add target/ before the usual subdir return os.path.join('target', third_party_utils.default_uniq_cfg_path())
def get_link_args(): link_args = \ third_party_utils.default_get_link_args('qthread', ucp=get_uniq_cfg_path(), libs=['libqthread_chpl.la', '-lchpl', 'libqthread.la']) if (chpl_compiler.get('target').startswith('cray-prgenv') and chpl_llvm.get() != 'none'): link_args.append('-lrt') return link_args
def get_uniq_cfg_path_for(llvm_val): if llvm_val == "llvm": # put platform-arch-compiler for included llvm host_bin_subdir = chpl_bin_subdir.get('host') host_compiler = chpl_compiler.get('host') llvm_target_dir = '{0}-{1}'.format(host_bin_subdir, host_compiler) else: # just put 'system' for system llvm llvm_target_dir = llvm_val return llvm_target_dir
def get_uniq_cfg_path_for(llvm_val): if llvm_val == "bundled": # put platform-arch-compiler for included llvm host_bin_subdir = chpl_bin_subdir.get('host') host_compiler = chpl_compiler.get('host') llvm_target_dir = '{0}-{1}'.format(host_bin_subdir, host_compiler) else: # just put 'system' for system llvm llvm_target_dir = llvm_val return llvm_target_dir
def get_link_args(): link_args = \ third_party_utils.default_get_link_args('qthread', ucp=get_uniq_cfg_path(), libs=['libqthread_chpl.la', '-lchpl', 'libqthread.la']) if ( chpl_compiler.get('target').startswith('cray-prgenv') and chpl_llvm.get() != 'none' ): link_args.append('-lrt') return link_args
def get(): launcher_val = overrides.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith( 'cray-x') or chpl_platform.is_cross_compiling(): has_aprun = find_executable('aprun') has_slurm = find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm or platform_val == 'aarch64': launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) sys.stderr.write( 'Warning: Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.\n') elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'smp': launcher_val = 'smp' elif substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'ofi': launcher_val = 'gasnetrun_ofi' elif substrate_val == 'psm': launcher_val = 'gasnetrun_psm' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def get_link_args(): # Qthreads may call back to the runtime, so re-search libchpl after. link_args = \ third_party_utils.default_get_link_args('qthread', ucp=get_uniq_cfg_path(), libs=['libqthread.la', '-lchpl']) compiler_val = chpl_compiler.get('target') if compiler_val == 'cray-prgenv-cray': link_args.append('-lrt') return link_args
def get_link_args(): link_args = \ third_party_utils.default_get_link_args('qthread', ucp=get_uniq_cfg_path(), libs=['libqthread_chpl.la', '-lchpl', 'libqthread.la']) compiler_val = chpl_compiler.get('target') if ( compiler_val == 'cray-prgenv-cray' or (compiler_is_prgenv(compiler_val) and chpl_llvm.get() != 'none' )): link_args.append('-lrt') return link_args
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: arch_val = chpl_arch.get('target', get_lcd=True) platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') if (arch_val == 'knc' or platform_val.startswith('cygwin') or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get_link_args(): link_args = \ third_party_utils.default_get_link_args('qthread', ucp=get_uniq_cfg_path(), libs=['libqthread_chpl.la', '-lchpl', 'libqthread.la']) compiler_val = chpl_compiler.get('target') if compiler_val == 'cray-prgenv-cray': link_args.append('-lrt') return link_args
def default_cpu(flag): comm_val = chpl_comm.get() compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) cpu = 'unknown' if comm_val == 'none' and ('linux' in platform_val or platform_val == 'darwin' or platform_val.startswith('cygwin')): cpu = 'native' return cpu
def get(): tasks_val = overrides.get('CHPL_TASKS') if not tasks_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if (platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or platform_val.startswith('freebsd')): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def adjust_architecture_for_compiler(arch, flag, get_lcd): compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = compiler_is_prgenv(compiler_val) if compiler_val == 'clang-included': isprgenv = compiler_is_prgenv(chpl_compiler.get(flag, llvm_mode="orig")) if isprgenv: cray_arch = os.environ.get('CRAY_CPU_TARGET', 'none') if arch and (arch != 'none' and arch != 'unknown' and arch != cray_arch): stderr.write("Warning: Setting the processor type through " "environment variables is not supported for " "cray-prgenv-*. Please use the appropriate craype-* " "module for your processor type.\n") arch = cray_arch if arch == 'none': stderr.write( "Warning: No craype-* processor type module was " "detected, please load the appropriate one if you want " "any specialization to occur.\n") if get_lcd: arch = get_module_lcd_arch(platform_val, arch) if arch == 'none': stderr.write("Warning: Could not detect the lowest common " "denominator processor type for this platform. " "You may be unable to use the Chapel compiler\n") return arch elif 'pgi' in compiler_val: return 'none' elif 'cray' in compiler_val: return 'none' elif 'ibm' in compiler_val: return 'none' return arch
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') comm_val = chpl_comm.get() if (platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): llvm_val = os.environ.get("CHPL_LLVM") if not llvm_val: host_platform = chpl_platform.get("host") host_compiler = chpl_compiler.get("host") chpl_home = utils.get_chpl_home() llvm_target_dir = "{0}-{1}".format(host_platform, host_compiler) llvm_subdir = os.path.join(chpl_home, "third-party", "llvm", "install", llvm_target_dir) llvm_header = os.path.join(llvm_subdir, "include", "llvm", "PassSupport.h") if os.path.exists(llvm_header): llvm_val = "llvm" else: llvm_val = "none" return llvm_val
def get(): regexp_val = os.environ.get('CHPL_REGEXP') if not regexp_val: target_platform = chpl_platform.get('target') target_compiler = chpl_compiler.get('target') chpl_home = utils.get_chpl_home() regexp_target_dir = '{0}-{1}'.format(target_platform, target_compiler) regexp_subdir = os.path.join(chpl_home, 'third-party', 're2', 'install', regexp_target_dir) regexp_header = os.path.join(regexp_subdir, 'include', 're2', 're2.h') if os.path.exists(regexp_header): regexp_val = 're2' else: regexp_val = 'none' return regexp_val
def get(): llvm_val = os.environ.get('CHPL_LLVM') if not llvm_val: host_platform = chpl_platform.get('host') host_compiler = chpl_compiler.get('host') chpl_home = utils.get_chpl_home() llvm_target_dir = '{0}-{1}'.format(host_platform, host_compiler) llvm_subdir = os.path.join(chpl_home, 'third-party', 'llvm', 'install', llvm_target_dir) llvm_header = os.path.join(llvm_subdir, 'include', 'llvm', 'PassSupport.h') if os.path.exists(llvm_header): llvm_val = 'llvm' else: llvm_val = 'none' return llvm_val
def get(): regexp_val = os.environ.get('CHPL_REGEXP') if not regexp_val: target_platform = chpl_platform.get('target') target_compiler = chpl_compiler.get('target') target_arch = chpl_arch.get('target', map_to_compiler=True, get_lcd=True) chpl_home = utils.get_chpl_home() regexp_target_dir = '{0}-{1}-{2}'.format(target_platform, target_compiler, target_arch) regexp_subdir = os.path.join(chpl_home, 'third-party', 're2', 'install', regexp_target_dir) regexp_header = os.path.join(regexp_subdir, 'include', 're2', 're2.h') if os.path.exists(regexp_header): regexp_val = 're2' else: regexp_val = 'none' return regexp_val
def get(flag='target'): if flag == 'network': atomics_val = overrides.get('CHPL_NETWORK_ATOMICS') if not atomics_val: comm_val = chpl_comm.get() if comm_val in ['ofi', 'ugni'] and get('target') != 'locks': atomics_val = comm_val else: atomics_val = 'none' elif flag == 'target': atomics_val = overrides.get('CHPL_ATOMICS') if not atomics_val: compiler_val = chpl_compiler.get('target') platform_val = chpl_platform.get('target') # we currently support intrinsics for gcc, intel, cray and clang. # gcc added initial support in 4.1, and added support for 64 bit # atomics on 32 bit platforms with 4.8. clang and intel also # support 64 bit atomics on 32 bit platforms and the cray compiler # will never run on a 32 bit machine. For pgi or 32 bit platforms # with an older gcc, we fall back to locks if compiler_val in [ 'gnu', 'cray-prgenv-gnu', 'mpi-gnu', 'aarch64-gnu' ]: version = get_compiler_version('gnu') if version >= CompVersion('4.8'): atomics_val = 'intrinsics' elif version >= CompVersion( '4.1') and not platform_val.endswith('32'): atomics_val = 'intrinsics' elif compiler_val == 'intel' or compiler_val == 'cray-prgenv-intel': atomics_val = 'intrinsics' elif compiler_val == 'cray-prgenv-cray': atomics_val = 'intrinsics' elif compiler_val in ['allinea', 'cray-prgenv-allinea']: atomics_val = 'cstdlib' elif compiler_val == 'clang': atomics_val = 'intrinsics' elif compiler_val == 'clang-included': atomics_val = 'intrinsics' # we can't use intrinsics, fall back to locks if not atomics_val: atomics_val = 'locks' else: error("Invalid flag: '{0}'".format(flag), ValueError) return atomics_val
def get(): tasks_val = overrides.get('CHPL_TASKS') if not tasks_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') arch_val = chpl_arch.get('target') cygwin = platform_val.startswith('cygwin') bsd = (platform_val.startswith('netbsd') or platform_val.startswith('freebsd')) mac_arm = platform_val.startswith('darwin') and arch_val == 'arm64' if cygwin or bsd or mac_arm: tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): launcher_val = os.environ.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith('cray-x'): has_aprun = utils.find_executable('aprun') has_slurm = utils.find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm: launcher_val = 'slurm-srun' elif platform_val == 'marenostrum': launcher_val = 'marenostrum' elif compiler_val == 'tile-cc': launcher_val = 'tile-monitor' elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': if platform_val == 'pwr6': # our loadleveler launcher is not yet portable/stable/ # flexible enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' else: launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'lapi': # our loadleveler launcher is not yet portable/stable/flexible # enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' return launcher_val
def get(flag='target'): if flag == 'network': atomics_val = os.environ.get('CHPL_NETWORK_ATOMICS') if not atomics_val: if chpl_comm.get() == 'ugni': atomics_val = 'ugni' else: atomics_val = 'none' elif flag == 'target': atomics_val = os.environ.get('CHPL_ATOMICS') if not atomics_val: compiler_val = chpl_compiler.get('target') platform_val = chpl_platform.get('target') # we currently support intrinsics for gcc, intel, cray and clang. # gcc added initial support in 4.1, and added support for 64 bit # atomics on 32 bit platforms with 4.8. clang and intel also # support 64 bit atomics on 32 bit platforms and the cray compiler # will never run on a 32 bit machine. For pgi or 32 bit platforms # with an older gcc, we fall back to locks if compiler_val == 'gnu' or compiler_val == 'cray-prgenv-gnu': version = utils.get_compiler_version('gnu') if version.major > 4: atomics_val = 'intrinsics' if version.major == 4: if version.minor >= 8: atomics_val = 'intrinsics' elif version.minor >= 1 and not platform_val.endswith( '32'): atomics_val = 'intrinsics' elif compiler_val == 'intel' or compiler_val == 'cray-prgenv-intel': atomics_val = 'intrinsics' elif compiler_val == 'cray-prgenv-cray': atomics_val = 'intrinsics' elif compiler_val == 'clang': atomics_val = 'intrinsics' elif compiler_val == 'clang-included': atomics_val = 'intrinsics' # we can't use intrinsics, fall back to locks if not atomics_val: atomics_val = 'locks' else: raise ValueError("Invalid flag: '{0}'".format(flag)) return atomics_val
def get(): gmp_val = os.environ.get('CHPL_GMP') if not gmp_val: target_platform = chpl_platform.get('target') target_compiler = chpl_compiler.get('target') if target_platform.startswith('cray-x'): gmp_val = 'system' else: chpl_home = utils.get_chpl_home() gmp_target_dir = '{0}-{1}'.format(target_platform, target_compiler) gmp_subdir = os.path.join(chpl_home, 'third-party', 'gmp', 'install', gmp_target_dir) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'gmp' else: gmp_val = 'none' return gmp_val
def get(): comm_val = overrides.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') # use ugni on cray-x* machines using the module and supported compiler ugni_comp = ('cray-prgenv-gnu', 'cray-prgenv-intel', 'cray-prgenv-cray') if (platform_val.startswith('cray-x') and using_chapel_module() and compiler_val in ugni_comp): comm_val = 'ugni' # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def get(): tasks_val = os.environ.get("CHPL_TASKS") if not tasks_val: arch_val = chpl_arch.get("target", get_lcd=True) platform_val = chpl_platform.get() compiler_val = chpl_compiler.get("target") comm_val = chpl_comm.get() if ( arch_val == "knc" or platform_val.startswith("cygwin") or platform_val.startswith("netbsd") or compiler_val == "cray-prgenv-cray" ): tasks_val = "fifo" else: tasks_val = "qthreads" return tasks_val
def get(): comm_val = os.environ.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') # use ugni on cray-x* machines using the module and supported compiler ugni_comp = ('cray-prgenv-gnu', 'cray-prgenv-intel', 'cray-prgenv-cray') if (platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ugni_comp): comm_val = 'ugni' # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def adjust_cpu_for_compiler(cpu, flag, get_lcd): compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = flag == 'target' and target_compiler_is_prgenv() if isprgenv: cray_cpu = os.environ.get('CRAY_CPU_TARGET', 'none') has_cpu = cpu and cpu != 'none' and cpu != 'unknown' has_cray_cpu = cray_cpu and cray_cpu != 'none' and cray_cpu != 'unknown' if compiler_val == 'llvm': # if the CPU type is not set, use the cray_cpu, # but allow overriding it with CHPL_TARGET_CPU. if has_cray_cpu and not has_cpu: cpu = cray_cpu else: # for C compilation, CPU needs to be set by cray-prgenv-* # and not by e.g. CHPL_TARGET_CPU. cpu = cray_cpu if has_cpu: warning("Setting the processor type through environment " "variables is not supported for cray-prgenv-*. " "Please use the appropriate craype-* module for your " "processor type.") if not has_cray_cpu: warning("No craype-* processor type module was detected, " "please load the appropriate one if you want any " "specialization to occur.") if get_lcd: cpu = get_module_lcd_cpu(platform_val, cpu) if cpu == 'none': warning("Could not detect the lowest common denominator " "processor type for this platform. You may be unable " "to use the Chapel compiler") return cpu elif 'pgi' in compiler_val: return 'none' elif 'cray' in compiler_val: return 'none' elif 'ibm' in compiler_val: return 'none' return cpu
def get(flag='target'): if flag == 'network': atomics_val = os.environ.get('CHPL_NETWORK_ATOMICS') if not atomics_val: if chpl_comm.get() == 'ugni': atomics_val = 'ugni' else: atomics_val = 'none' elif flag == 'target': atomics_val = os.environ.get('CHPL_ATOMICS') if not atomics_val: compiler_val = chpl_compiler.get('target') platform_val = chpl_platform.get('target') # we currently support intrinsics for gcc, intel, cray and clang. # gcc added initial support in 4.1, and added support for 64 bit # atomics on 32 bit platforms with 4.8. clang and intel also # support 64 bit atomics on 32 bit platforms and the cray compiler # will never run on a 32 bit machine. For pgi or 32 bit platforms # with an older gcc, we fall back to locks if compiler_val == 'gnu' or compiler_val == 'cray-prgenv-gnu': version = utils.get_compiler_version('gnu') if version.major > 4: atomics_val = 'intrinsics' if version.major == 4: if version.minor >= 8: atomics_val = 'intrinsics' elif version.minor >= 1 and not platform_val.endswith('32'): atomics_val = 'intrinsics' elif compiler_val == 'intel' or compiler_val == 'cray-prgenv-intel': atomics_val = 'intrinsics' elif compiler_val == 'cray-prgenv-cray': atomics_val = 'intrinsics' elif compiler_val == 'clang': atomics_val = 'intrinsics' elif compiler_val == 'clang-included': atomics_val = 'intrinsics' # we can't use intrinsics, fall back to locks if not atomics_val: atomics_val = 'locks' else: raise ValueError("Invalid flag: '{0}'".format(flag)) return atomics_val
def get(flag='target'): if flag == 'network': atomics_val = overrides.get('CHPL_NETWORK_ATOMICS') if not atomics_val: if chpl_comm.get() == 'ugni' and get('target') != 'locks': atomics_val = 'ugni' else: atomics_val = 'none' elif flag == 'target': atomics_val = overrides.get('CHPL_ATOMICS') if not atomics_val: compiler_val = chpl_compiler.get('target') platform_val = chpl_platform.get('target') # we currently support intrinsics for gcc, intel, cray and clang. # gcc added initial support in 4.1, and added support for 64 bit # atomics on 32 bit platforms with 4.8. clang and intel also # support 64 bit atomics on 32 bit platforms and the cray compiler # will never run on a 32 bit machine. For pgi or 32 bit platforms # with an older gcc, we fall back to locks if compiler_val in ['gnu', 'cray-prgenv-gnu', 'mpi-gnu', 'aarch64-gnu']: version = get_compiler_version('gnu') if version >= CompVersion('4.8'): atomics_val = 'intrinsics' elif version >= CompVersion('4.1') and not platform_val.endswith('32'): atomics_val = 'intrinsics' elif compiler_val == 'intel' or compiler_val == 'cray-prgenv-intel': atomics_val = 'intrinsics' elif compiler_val == 'cray-prgenv-cray': atomics_val = 'intrinsics' elif compiler_val in ['allinea', 'cray-prgenv-allinea']: atomics_val = 'cstdlib' elif compiler_val == 'clang': atomics_val = 'intrinsics' elif compiler_val == 'clang-included': atomics_val = 'intrinsics' # we can't use intrinsics, fall back to locks if not atomics_val: atomics_val = 'locks' else: error("Invalid flag: '{0}'".format(flag), ValueError) return atomics_val
def get(): tasks_val = overrides.get("CHPL_TASKS") if not tasks_val: platform_val = chpl_platform.get("target") compiler_val = chpl_compiler.get("target") # CCE >= 8.4 is required to build qthreads (for gnu style inline asm.) # We build the module with a new enough version so we know the we can # use the qthreads it provides even if the user has an older CCE loaded using_qthreads_incompatible_cce = False if compiler_val == "cray-prgenv-cray": if get_compiler_version(compiler_val) < CompVersion("8.4") and not using_chapel_module(): using_qthreads_incompatible_cce = True if platform_val.startswith("cygwin") or platform_val.startswith("netbsd") or using_qthreads_incompatible_cce: tasks_val = "fifo" else: tasks_val = "qthreads" return tasks_val
def verify_arch(arch, flag): comm_val = chpl_comm.get() compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = compiler_is_prgenv(compiler_val) # Only try to do any architecture verification when: # comm == none -- The inverse means that we are probably cross-compiling. # # linux/dawin/ -- The only platforms that we should try and detect on. # cygwin Crays will be handled through the craype-* modules # check_arch = False if not isprgenv: if flag == 'target': if comm_val == 'none': if ('linux' in platform_val or platform_val == 'darwin' or platform_val.startswith('cygwin')): check_arch = True if flag == 'host': check_arch = True if check_arch and arch and arch not in ['none', 'unknown', 'native']: # Print a friendly warning if it's unlikely the user could run # their program. This could be printed in cross-compilation settings. machine = machine_for_arch(arch) cur_machine = get_native_machine() warn = (machine != cur_machine) try: vendor_string, feature_string = get_cpuinfo(platform_val) detected_arch = feature_sets.find(vendor_string, feature_string) if not feature_sets.subset(arch, detected_arch): warn = True except ValueError: stderr.write( "Warning: Unknown platform, could not find CPU information\n") if warn: stderr.write("Warning: The supplied processor type does " "not appear to be compatible with the host " "processor type. The resultant binary may " "not run on the current machine.\n")
def get(flag, map_to_compiler=False, get_lcd=False): arch_tuple = collections.namedtuple('arch_tuple', ['flag', 'arch']) if not flag or flag == 'host': arch = overrides.get('CHPL_HOST_ARCH', '') elif flag == 'target': arch = overrides.get('CHPL_TARGET_ARCH', '') else: raise InvalidLocationError(flag) # fast path out for when the user has set arch=none if arch == 'none' or (flag == 'host' and not arch): return arch_tuple('none', 'none') # Adjust arch for compiler (not all compilers support all arch # settings; PrgEnv might override arch, etc) arch = adjust_architecture_for_compiler(arch, flag, get_lcd) # Now, if is not yet set, we should set the default. if not arch: arch = default_arch(flag) verify_arch(arch, flag) compiler_val = chpl_compiler.get(flag) isprgenv = compiler_is_prgenv(compiler_val) if map_to_compiler and not isprgenv: # Map flag/arch to compiler flag/argument # Don't do this for PrgEnv compiles since the compiler driver # handles specialization. version = get_compiler_version(compiler_val) (flag, arch) = argument_map.find(arch, compiler_val, version) elif arch and arch != 'none' and arch != 'unknown': if is_known_arm(arch): flag = 'cpu' else: flag = 'arch' else: flag = 'none' return arch_tuple(flag or 'none', arch or 'unknown')
def get(flag, map_to_compiler=False, get_lcd=False): cpu_tuple = collections.namedtuple('cpu_tuple', ['flag', 'cpu']) if not flag or flag == 'host': cpu = overrides.get('CHPL_HOST_CPU', '') elif flag == 'target': cpu = overrides.get('CHPL_TARGET_CPU', '') else: raise InvalidLocationError(flag) # fast path out for when the user has set arch=none if cpu == 'none' or (flag == 'host' and not cpu): return cpu_tuple('none', 'none') compiler_val = chpl_compiler.get(flag) # Adjust cpu for compiler (not all compilers support all cpu # settings; PrgEnv might override cpu, etc) cpu = adjust_cpu_for_compiler(cpu, flag, get_lcd) # support additional cpu synonyms for llvm/gcc/clang if map_to_compiler: if compiler_val in ('llvm', 'gnu', 'clang'): if cpu in cpu_llvm_synonyms: cpu = cpu_llvm_synonyms[cpu] # Now, if is not yet set, we should set the default. if not cpu: cpu = default_cpu(flag) argname = None if cpu and cpu != 'none' and cpu != 'unknown': # x86 uses -march= where the others use -mcpu= if is_x86_variant(get_native_machine()): argname = 'arch' else: argname = 'cpu' else: argname = 'none' return cpu_tuple(argname or 'none', cpu or 'unknown')
def get(flag='host'): if flag == 'host': mem_val = 'cstdlib' elif flag == 'target': mem_val = os.environ.get('CHPL_MEM') if not mem_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') cygwin = platform_val.startswith('cygwin') pgi = 'pgi' in compiler_val gnu_darwin = platform_val == 'darwin' and compiler_val == 'gnu' if cygwin or pgi or gnu_darwin: mem_val = 'cstdlib' else: mem_val = 'jemalloc' else: raise ValueError("Invalid flag: '{0}'".format(flag)) return mem_val
def get(): gmp_val = os.environ.get('CHPL_GMP') if not gmp_val: target_platform = chpl_platform.get('target') target_compiler = chpl_compiler.get('target') target_arch = chpl_arch.get('target', map_to_compiler=True, get_lcd=True) # Detect if gmp has been built for this configuration. chpl_home = utils.get_chpl_home() gmp_target_dir = '{0}-{1}-{2}'.format(target_platform, target_compiler, target_arch) gmp_subdir = os.path.join(chpl_home, 'third-party', 'gmp', 'install', gmp_target_dir) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'gmp' elif target_platform.startswith('cray-x'): gmp_val = 'system' else: gmp_val = 'none' return gmp_val
def get(flag="target"): if flag == "network": atomics_val = os.environ.get("CHPL_NETWORK_ATOMICS") if not atomics_val: if chpl_comm.get() == "ugni": atomics_val = "ugni" else: atomics_val = "none" elif flag == "target": atomics_val = os.environ.get("CHPL_ATOMICS") if not atomics_val: compiler_val = chpl_compiler.get("target") platform_val = chpl_platform.get("target") # we currently support intrinsics for gcc, intel, cray and clang. # gcc added initial support in 4.1, and added support for 64 bit # atomics on 32 bit platforms with 4.8. clang and intel also # support 64 bit atomics on 32 bit platforms and the cray compiler # will never run on a 32 bit machine. For pgi or 32 bit platforms # with an older gcc, we fall back to locks if compiler_val == "gnu" or compiler_val == "cray-prgenv-gnu": version = utils.get_compiler_version("gnu") if version >= CompVersion("4.8"): atomics_val = "intrinsics" elif version >= CompVersion("4.1") and not platform_val.endswith("32"): atomics_val = "intrinsics" elif compiler_val == "intel" or compiler_val == "cray-prgenv-intel": atomics_val = "intrinsics" elif compiler_val == "cray-prgenv-cray": atomics_val = "intrinsics" elif compiler_val == "clang": atomics_val = "intrinsics" elif compiler_val == "clang-included": atomics_val = "intrinsics" # we can't use intrinsics, fall back to locks if not atomics_val: atomics_val = "locks" else: raise ValueError("Invalid flag: '{0}'".format(flag)) return atomics_val
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: arch_val = chpl_arch.get('target', get_lcd=True) platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') comm_val = chpl_comm.get() # use muxed on cray-x* machines using the module and supported compiler if (comm_val == 'ugni' and platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ('cray-prgenv-gnu', 'cray-prgenv-intel') and arch_val != 'knc'): tasks_val = 'muxed' elif (arch_val == 'knc' or platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def verify_cpu(cpu, flag): comm_val = chpl_comm.get() compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = compiler_is_prgenv(compiler_val) # Only try to do any architecture verification when: # comm == none -- The inverse means that we are probably cross-compiling. # # linux/dawin/ -- The only platforms that we should try and detect on. # cygwin Crays will be handled through the craype-* modules # check_cpu = False if not isprgenv: if flag == 'target': if comm_val == 'none': if ('linux' in platform_val or platform_val == 'darwin' or platform_val.startswith('cygwin')): check_cpu = True if flag == 'host': check_cpu = True if check_cpu and cpu and cpu not in ['none', 'unknown', 'native']: # Print a friendly warning if it's unlikely the user could run # their program. This could be printed in cross-compilation settings. warn = False try: vendor_string, feature_string = get_cpuinfo(platform_val) detected_cpu = feature_sets.find(vendor_string, feature_string) if not feature_sets.subset(cpu, detected_cpu): warn = True except ValueError: stderr.write("Warning: Unknown platform, could not find CPU information\n") if warn: stderr.write("Warning: The supplied processor type does " "not appear to be compatible with the host " "processor type. The resultant binary may " "not run on the current machine.\n")
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') # CCE >= 8.4 is required to build qthreads (for gnu style inline asm.) # We build the module with a new enough version so we know the we can # use the qthreads it provides even if the user has an older CCE loaded using_qthreads_incompatible_cce = False if compiler_val == 'cray-prgenv-cray': if (utils.get_compiler_version(compiler_val) < CompVersion('8.4') and not using_chapel_module()): using_qthreads_incompatible_cce = True if (platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or using_qthreads_incompatible_cce): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): gmp_val = overrides.get('CHPL_GMP') if not gmp_val: target_compiler = chpl_compiler.get('target') if target_compiler == 'cray-prgenv-cray': gmp_val = 'system' else: target_platform = chpl_platform.get('target') # Detect if gmp has been built for this configuration. third_party = get_chpl_third_party() uniq_cfg_path = chpl_3p_gmp_configs.get_uniq_cfg_path() gmp_subdir = os.path.join(third_party, 'gmp', 'install', uniq_cfg_path) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'gmp' elif target_platform.startswith('cray-x'): gmp_val = 'system' elif target_platform == 'aarch64': gmp_val = 'system' else: gmp_val = 'none' return gmp_val
def get(flag='target'): if flag == 'network': atomics_val = os.environ.get('CHPL_NETWORK_ATOMICS') if not atomics_val: if chpl_comm.get() == 'ugni': atomics_val = 'ugni' else: atomics_val = 'none' elif flag == 'target': atomics_val = os.environ.get('CHPL_ATOMICS') if not atomics_val: compiler_val = chpl_compiler.get('target') platform_val = chpl_platform.get('target') # we currently support intrinsics for 64 bit platforms using gcc, # intel, or cray compilers but not pgi. pgi does not have support # for atomic intrinsics so we revert to locks for that case. We # could add support for 32-bit platforms and only use locks for # 64-bit atomics but we can cross that bridge when we get there. if platform_val != "linux32": if compiler_val == 'gnu' or compiler_val == 'cray-prgenv-gnu': version = utils.get_compiler_version('gnu') if version >= 4.1: atomics_val = 'intrinsics' elif 'intel' in compiler_val or compiler_val == 'cray-prgenv-intel': atomics_val = 'intrinsics' elif compiler_val == 'cray-prgenv-cray': atomics_val = 'intrinsics' elif 'clang' in compiler_val: atomics_val = 'intrinsics' # we can't use intrinsics, fall back to locks if not atomics_val: atomics_val = 'locks' else: raise ValueError("Invalid flag: '{0}'".format(flag)) return atomics_val