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 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(flag='target'): if flag == 'network': atomics_val = overrides.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 = 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']: 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 == 'aarch64-gnu': atomics_val = 'cstdlib' 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: 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 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(): 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 get(location, map_to_compiler=False, get_lcd=False): arch_tuple = collections.namedtuple('arch_tuple', ['flag', 'arch']) if not location or location == "host": arch = overrides.get('CHPL_HOST_ARCH', '') elif location == 'target': arch = overrides.get('CHPL_TARGET_ARCH', '') else: raise InvalidLocationError(location) # fast path out for when the user has set arch=none if arch == 'none': return arch_tuple('none', arch) comm_val = chpl_comm.get() compiler_val = chpl_compiler.get(location) platform_val = chpl_platform.get(location) isprgenv = compiler_is_prgenv(compiler_val) if compiler_val == 'clang-included': isprgenv = compiler_is_prgenv( chpl_compiler.get(location, 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") if is_known_arm(arch): return arch_tuple('cpu', arch) else: return arch_tuple('arch', arch) elif 'pgi' in compiler_val: return arch_tuple('none', 'none') elif 'cray' in compiler_val: return arch_tuple('none', 'none') elif 'ibm' in compiler_val: return arch_tuple('none', 'none') # Only try to do any auto-detection or 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 # if comm_val == 'none' and ('linux' in platform_val or platform_val == 'darwin' or platform_val.startswith('cygwin')): if arch and arch not in ['none', 'unknown', 'native']: if location == 'host': # when a user supplies an architecture, and it seems reasonable # to double check their choice we do so. This will only # generate a warning that the user may not be able to run # whatever they compile. # # This only runs when location is 'host' since we # conservatively assume that a setting for 'target' could be in # a cross-compilation setting 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): 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") except ValueError: stderr.write( "Warning: Unknown platform, could not find CPU information\n" ) else: # Clang cannot detect the architecture for aarch64. Otherwise, # let the backend compiler do the actual feature set detection. We # could be more aggressive in setting a precise architecture using # the double checking code above, but it seems like a waste of time # to not use the work the backend compilers have already done if compiler_val in ['clang', 'clang-included']: if get_native_machine() == 'aarch64': arch = 'unknown' else: arch = 'native' else: arch = 'native' if map_to_compiler: 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') # 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 = flag == 'target' and target_compiler_is_prgenv( not map_to_compiler) 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) 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='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 default to C standard atomics (cstdlib) for gcc 5 and newer. # Some prior versions of gcc look like they support standard # atomics, but have buggy or missing parts of the implementation, # so we do not try to use cstdlib with gcc < 5. If support is # detected for clang (via preprocessor checks) we also default to # cstdlib atomics. For llvm/clang-included we always default to # cstdlib atomics. We know our clang-included will have compiler # support for atomics and llvm requires gcc 4.8 (or a compiler with # equivalent features) to be built so we know we'll have system # header support too. # # We 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']: version = get_compiler_version('gnu') if version >= CompVersion('5.0'): atomics_val = 'cstdlib' elif 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 = 'cstdlib' elif compiler_val in ['allinea', 'cray-prgenv-allinea']: atomics_val = 'cstdlib' elif compiler_val == 'clang': if has_std_atomics(compiler_val): atomics_val = 'cstdlib' else: atomics_val = 'intrinsics' elif compiler_val == 'clang-included': atomics_val = 'cstdlib' # 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(location, map_to_compiler=False, get_lcd=False): arch_tuple = collections.namedtuple('arch_tuple', ['flag', 'arch']) if not location or location == "host": arch = overrides.get('CHPL_HOST_ARCH', '') elif location == 'target': arch = overrides.get('CHPL_TARGET_ARCH', '') else: raise InvalidLocationError(location) # fast path out for when the user has set arch=none if arch == 'none': return arch_tuple('none', arch) comm_val = chpl_comm.get() compiler_val = chpl_compiler.get(location) platform_val = chpl_platform.get(location) isprgenv = compiler_is_prgenv(compiler_val) if compiler_val == 'clang-included': isprgenv = compiler_is_prgenv(chpl_compiler.get(location, 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") if is_known_arm(arch): return arch_tuple('cpu', arch) else: return arch_tuple('arch', arch) elif 'pgi' in compiler_val: return arch_tuple('none', 'none') elif 'cray' in compiler_val: return arch_tuple('none', 'none') elif 'ibm' in compiler_val: return arch_tuple('none', 'none') # Only try to do any auto-detection or 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 # if comm_val == 'none' and ('linux' in platform_val or platform_val == 'darwin' or platform_val.startswith('cygwin')): if arch and arch not in ['none', 'unknown', 'native']: if location == 'host': # when a user supplies an architecture, and it seems reasonable # to double check their choice we do so. This will only # generate a warning that the user may not be able to run # whatever they compile. # # This only runs when location is 'host' since we # conservatively assume that a setting for 'target' could be in # a cross-compilation setting 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): 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") except ValueError: stderr.write("Warning: Unknown platform, could not find CPU information\n") else: # Clang cannot detect the architecture for aarch64. Otherwise, # let the backend compiler do the actual feature set detection. We # could be more aggressive in setting a precise architecture using # the double checking code above, but it seems like a waste of time # to not use the work the backend compilers have already done if compiler_val in ['clang', 'clang-included']: if get_native_machine() == 'aarch64': arch = 'unknown' else: arch = 'native' else: arch = 'native' if map_to_compiler: 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='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 default to C standard atomics (cstdlib) for gcc 5 and newer. # Some prior versions of gcc look like they support standard # atomics, but have buggy or missing parts of the implementation, # so we do not try to use cstdlib with gcc < 5. If support is # detected for clang (via preprocessor checks) we also default to # cstdlib atomics. For llvm/clang-included we always default to # cstdlib atomics. We know our clang-included will have compiler # support for atomics and llvm requires gcc 4.8 (or a compiler with # equivalent features) to be built so we know we'll have system # header support too. # # We 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']: version = get_compiler_version('gnu') if version >= CompVersion('5.0'): atomics_val = 'cstdlib' elif 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': if has_std_atomics(compiler_val): atomics_val = 'cstdlib' else: atomics_val = 'intrinsics' elif compiler_val == 'clang-included': atomics_val = 'cstdlib' # 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