#ifdef KERNELLIB_HOST_DISTRO_VARIANTS
const struct kernellib_features {
const char *kernellib_name;
+ const char *cpu_name;
const char *features[12];
} kernellib_feature_map[] = {
// order the entries s.t. if a cpu matches multiple entries, the "best" match
// comes last
#if defined(__x86_64__)
"sse2",
+ "athlon64",
{"sse2", NULL},
"ssse3",
+ "core2",
{"sse2", "ssse3", "cx16", NULL},
"sse41",
+ "penryn",
{"sse2", "sse4.1", "cx16", NULL},
"avx",
+ "sandybridge",
{"sse2", "avx", "cx16", "popcnt", NULL},
"avx_f16c",
+ "ivybridge",
{"sse2", "avx", "cx16", "popcnt", "f16c", NULL},
"avx_fma4",
+ "bdver1",
{"sse2", "avx", "cx16", "popcnt", "xop", "fma4", NULL},
"avx2",
+ "haswell",
{"sse2", "avx", "avx2", "cx16", "popcnt", "lzcnt", "f16c", "fma", "bmi",
"bmi2", NULL},
"avx512",
+ "skylake-avx512",
{"sse2", "avx512f", NULL},
#endif
+ NULL,
NULL,
{NULL}};
return best_match->kernellib_name;
}
+
+/* for "distro" style kernel libs, return which target cpu to use for a given
+ * kernellib */
+const char *pocl_get_distro_cpu_name(const char *kernellib_name) {
+ StringMap<bool> Features;
+
+ if (!llvm::sys::getHostCPUFeatures(Features))
+ POCL_ABORT("LLVM can't get host CPU flags!\n");
+
+ const kernellib_features *best_match = NULL;
+ for (const kernellib_features *kf = kernellib_feature_map; kf->kernellib_name;
+ ++kf) {
+ if (!strcmp(kernellib_name, kf->kernellib_name))
+ return kf->cpu_name;
+ }
+
+ POCL_ABORT("Can't find a cpu name matching the kernellib (%s)\n",
+ kernellib_name);
+}
#endif
int bitcode_is_triple(const char *bitcode, size_t size, const char *triple) {