def cpu(is_x86, is_64bit): cpu = CpuFeatures(name=platform.processor(), vendor=platform.platform(), arch=platform.machine(), sse41=False, sse42=False, aes=False, avx=False, avx2=False) if is_x86: from cpuid import _is_set, cpu_vendor, cpu_name, cpu_microarchitecture cpu = CpuFeatures( name=cpu_name().rstrip('\x00'), vendor=cpu_vendor(), arch=cpu_microarchitecture()[0], sse41=_is_set(1, 2, 19) == 'Yes', sse42=_is_set(1, 2, 20) == 'Yes', aes=_is_set(1, 2, 25) == 'Yes', avx=_is_set(1, 2, 28) == 'Yes', avx2=_is_set(7, 1, 5) == 'Yes', ) logging.getLogger().info("CPU %s", cpu) return cpu
def check_hardware(): """ checks the hardware """ print("Checking Hardware:") print(" => Vendor ID : %s" % cpu_vendor()) print(" => CPU name : %s" % cpu_name()) print(" => Microarchitecture : %s%s" % cpu_microarchitecture()) print(" => Vector instructions supported:") print(" -> SSE : %s" % has_instruction(1, 3, 25)) print(" -> SSE2 : %s" % has_instruction(1, 3, 26)) print(" -> SSE3 : %s" % has_instruction(1, 2, 0)) print(" -> SSSE3 : %s" % has_instruction(1, 2, 9)) print(" -> SSE4.1 : %s" % has_instruction(1, 2, 19)) print(" -> SSE4.2 : %s" % has_instruction(1, 2, 20)) print(" -> SSE4a : %s" % has_instruction(0x80000001, 2, 6)) print(" -> AVX : %s" % has_instruction(1, 2, 28)) print(" -> AVX2 : %s" % has_instruction(7, 1, 5)) print(" -> BMI1 : %s" % has_instruction(7, 1, 3)) print(" -> BMI2 : %s" % has_instruction(7, 1, 8)) print("\n") if has_instruction(1, 2, 28) != "Yes": print(" => ATTENTION: instruction set AVX is needed")
import logging import cpuid def log(farg, *args): lgr.info(farg, *args) cpu_uarch = cpuid.cpu_microarchitecture()[0] fn = 'results-latencies/' + cpu_uarch + '.log' lgr = logging.getLogger('tlblatency') fh = logging.FileHandler(fn) lgr.setLevel(logging.DEBUG) fh.setLevel(logging.DEBUG) frmt = logging.Formatter('%(name)s - %(levelname)s - %(message)s') fh.setFormatter(frmt) lgr.addHandler(fh) sh = logging.StreamHandler() sh.setFormatter(frmt) lgr.addHandler(sh) log('logging to %s', fn)
def xor(a, b): return (a and not b) or (not a and b) if __name__ == "__main__": builder, name = get_builder() builder.add_common_builds(shared_option_name="%s:shared" % name) filtered_builds = [] for settings, options, env_vars, build_requires in builder.builds: if settings["build_type"] == "Release" \ and (not "compiler.runtime" in settings or xor(options["%s:shared" % name] == True, settings["compiler.runtime"] == "MT")): env_vars["BITPRIM_BUILD_NUMBER"] = os.getenv( 'BITPRIM_BUILD_NUMBER', '-') if os.getenv('BITPRIM_RUN_TESTS', 'false') == 'true': options["%s:with_tests" % name] = "True" options["*:currency"] = os.getenv('BITPRIM_CI_CURRENCY', '---') marchs = [ "x86_64", ''.join(cpuid.cpu_microarchitecture()), "haswell", "skylake" ] handle_microarchs("*:microarchitecture", marchs, filtered_builds, settings, options, env_vars, build_requires) builder.builds = filtered_builds builder.run()
def handle_microarchs(opt_name, microarchs, filtered_builds, settings, options, env_vars, build_requires): # print(microarchs) microarchs = list(set(microarchs)) # print(microarchs) for ma in microarchs: opts_copy = copy.deepcopy(options) opts_copy[opt_name] = ma filtered_builds.append([settings, opts_copy, env_vars, build_requires]) if __name__ == "__main__": builder = ConanMultiPackager(username="******", channel="stable", remotes="https://api.bintray.com/conan/bitprim/bitprim") builder.add_common_builds(shared_option_name="gmp:shared", pure_c=True) builder.password = os.getenv("CONAN_PASSWORD") filtered_builds = [] for settings, options, env_vars, build_requires in builder.builds: if settings["build_type"] == "Release" \ and settings["arch"] == "x86_64" \ and not ("gmp:shared" in options and options["gmp:shared"]): # marchs = ["x86_64", ''.join(cpuid.cpu_microarchitecture()), "haswell", "skylake", "ivybridge", "sandybridge"] marchs = ["x86_64", ''.join(cpuid.cpu_microarchitecture()), "haswell", "skylake"] handle_microarchs("gmp:microarchitecture", marchs, filtered_builds, settings, options, env_vars, build_requires) builder.builds = filtered_builds builder.run()
Vendor ID : {:s} CPU Name : {:s} Microarchitecture : {:s} '''.format( str(df), str(df.describe()), args.loop, df_mean['nps_e1'], df_std['nps_e1'], df_mean['nps_e2'], df_std['nps_e2'], df_mean['nps_diff'], df_std['nps_diff'], df_mean['nps_diff'] / df_mean['nps_e1'], statsmodels.stats.weightstats.ttest_ind(df['nps_e1'].values, df['nps_e2'].values, alternative='larger', usevar='unequal')[1], cpuid.cpu_vendor(), cpuid.cpu_name(), '%s%s' % cpuid.cpu_microarchitecture())) else: logger.info(''' {:s} {:s} Result of {:d} runs ================== base = {:10.0f} +/- {:.0f} Vendor ID : {:s} CPU Name : {:s} Microarchitecture : {:s}