Implement new naming scheme for --target.
Now targets are named like "<isa>-i<mask size>x<gang size>", e.g. "sse4-i8x16", or "avx2-i32x16". The old target names are still supported.
This commit is contained in:
116
ispc.cpp
116
ispc.cpp
@@ -106,7 +106,7 @@ static void __cpuidex(int info[4], int level, int count) {
|
||||
static const char *
|
||||
lGetSystemISA() {
|
||||
#ifdef __arm__
|
||||
return "neon-32";
|
||||
return "neon-i32x4";
|
||||
#else
|
||||
int info[4];
|
||||
__cpuid(info, 1);
|
||||
@@ -121,19 +121,19 @@ lGetSystemISA() {
|
||||
int info2[4];
|
||||
__cpuidex(info2, 7, 0);
|
||||
if ((info2[1] & (1 << 5)) != 0)
|
||||
return "avx2";
|
||||
return "avx2-i32x8";
|
||||
else
|
||||
return "avx1.1";
|
||||
return "avx1.1-i32x8";
|
||||
}
|
||||
// Regular AVX
|
||||
return "avx";
|
||||
return "avx-i32x8";
|
||||
}
|
||||
else if ((info[2] & (1 << 19)) != 0)
|
||||
return "sse4";
|
||||
return "sse4-i32x4";
|
||||
else if ((info[3] & (1 << 26)) != 0)
|
||||
return "sse2";
|
||||
return "sse2-i32x4";
|
||||
else {
|
||||
fprintf(stderr, "Unable to detect supported SSE/AVX ISA. Exiting.\n");
|
||||
Error(SourcePos(), "Unable to detect supported SSE/AVX ISA. Exiting.");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
@@ -186,22 +186,22 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
// If a CPU was specified explicitly, try to pick the best
|
||||
// possible ISA based on that.
|
||||
if (!strcmp(cpu, "core-avx2"))
|
||||
isa = "avx2";
|
||||
isa = "avx2-i32x8";
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
else if (!strcmp(cpu, "cortex-a9") ||
|
||||
!strcmp(cpu, "cortex-a15"))
|
||||
isa = "neon-32";
|
||||
isa = "neon-i32x4";
|
||||
#endif
|
||||
else if (!strcmp(cpu, "core-avx-i"))
|
||||
isa = "avx1.1";
|
||||
isa = "avx1.1-i32x8";
|
||||
else if (!strcmp(cpu, "sandybridge") ||
|
||||
!strcmp(cpu, "corei7-avx"))
|
||||
isa = "avx";
|
||||
isa = "avx-i32x8";
|
||||
else if (!strcmp(cpu, "corei7") ||
|
||||
!strcmp(cpu, "penryn"))
|
||||
isa = "sse4";
|
||||
isa = "sse4-i32x4";
|
||||
else
|
||||
isa = "sse2";
|
||||
isa = "sse2-i32x4";
|
||||
Warning(SourcePos(), "No --target specified on command-line. "
|
||||
"Using ISA \"%s\" based on specified CPU \"%s\".", isa,
|
||||
cpu);
|
||||
@@ -211,7 +211,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
// supports.
|
||||
isa = lGetSystemISA();
|
||||
Warning(SourcePos(), "No --target specified on command-line. "
|
||||
"Using system ISA \"%s\".", isa);
|
||||
"Using default system target \"%s\".", isa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +241,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
}
|
||||
}
|
||||
if (foundCPU == false) {
|
||||
fprintf(stderr, "Error: CPU type \"%s\" unknown. Supported CPUs: "
|
||||
"%s.\n", cpu, SupportedTargetCPUs().c_str());
|
||||
Error(SourcePos(), "Error: CPU type \"%s\" unknown. Supported CPUs: "
|
||||
"%s.", cpu, SupportedCPUs().c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
}
|
||||
|
||||
// Check default LLVM generated targets
|
||||
if (!strcasecmp(isa, "sse2")) {
|
||||
if (!strcasecmp(isa, "sse2") ||
|
||||
!strcasecmp(isa, "sse2-i32x4")) {
|
||||
this->m_isa = Target::SSE2;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
this->m_vectorWidth = 4;
|
||||
@@ -291,7 +292,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "sse2-x2")) {
|
||||
else if (!strcasecmp(isa, "sse2-x2") ||
|
||||
!strcasecmp(isa, "sse2-i32x8")) {
|
||||
this->m_isa = Target::SSE2;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -299,7 +301,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "sse4")) {
|
||||
else if (!strcasecmp(isa, "sse4") ||
|
||||
!strcasecmp(isa, "sse4-i32x4")) {
|
||||
this->m_isa = Target::SSE4;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
this->m_vectorWidth = 4;
|
||||
@@ -308,7 +311,9 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "sse4x2") || !strcasecmp(isa, "sse4-x2")) {
|
||||
else if (!strcasecmp(isa, "sse4x2") ||
|
||||
!strcasecmp(isa, "sse4-x2") ||
|
||||
!strcasecmp(isa, "sse4-i32x8")) {
|
||||
this->m_isa = Target::SSE4;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -316,7 +321,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "sse4-8")) {
|
||||
else if (!strcasecmp(isa, "sse4-i8x16")) {
|
||||
this->m_isa = Target::SSE4;
|
||||
this->m_nativeVectorWidth = 16;
|
||||
this->m_vectorWidth = 16;
|
||||
@@ -324,7 +329,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 8;
|
||||
}
|
||||
else if (!strcasecmp(isa, "sse4-16")) {
|
||||
else if (!strcasecmp(isa, "sse4-i16x8")) {
|
||||
this->m_isa = Target::SSE4;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -332,7 +337,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 16;
|
||||
}
|
||||
else if (!strcasecmp(isa, "generic-4")) {
|
||||
else if (!strcasecmp(isa, "generic-4") ||
|
||||
!strcasecmp(isa, "generic-x4")) {
|
||||
this->m_isa = Target::GENERIC;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
this->m_vectorWidth = 4;
|
||||
@@ -342,7 +348,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasTranscendentals = true;
|
||||
this->m_hasGather = this->m_hasScatter = true;
|
||||
}
|
||||
else if (!strcasecmp(isa, "generic-8")) {
|
||||
else if (!strcasecmp(isa, "generic-8") ||
|
||||
!strcasecmp(isa, "generic-x8")) {
|
||||
this->m_isa = Target::GENERIC;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -352,7 +359,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasTranscendentals = true;
|
||||
this->m_hasGather = this->m_hasScatter = true;
|
||||
}
|
||||
else if (!strcasecmp(isa, "generic-16")) {
|
||||
else if (!strcasecmp(isa, "generic-16") ||
|
||||
!strcasecmp(isa, "generic-x16")) {
|
||||
this->m_isa = Target::GENERIC;
|
||||
this->m_nativeVectorWidth = 16;
|
||||
this->m_vectorWidth = 16;
|
||||
@@ -362,7 +370,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasTranscendentals = true;
|
||||
this->m_hasGather = this->m_hasScatter = true;
|
||||
}
|
||||
else if (!strcasecmp(isa, "generic-32")) {
|
||||
else if (!strcasecmp(isa, "generic-32") ||
|
||||
!strcasecmp(isa, "generic-x32")) {
|
||||
this->m_isa = Target::GENERIC;
|
||||
this->m_nativeVectorWidth = 32;
|
||||
this->m_vectorWidth = 32;
|
||||
@@ -372,7 +381,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasTranscendentals = true;
|
||||
this->m_hasGather = this->m_hasScatter = true;
|
||||
}
|
||||
else if (!strcasecmp(isa, "generic-64")) {
|
||||
else if (!strcasecmp(isa, "generic-64") ||
|
||||
!strcasecmp(isa, "generic-x64")) {
|
||||
this->m_isa = Target::GENERIC;
|
||||
this->m_nativeVectorWidth = 64;
|
||||
this->m_vectorWidth = 64;
|
||||
@@ -382,14 +392,17 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasTranscendentals = true;
|
||||
this->m_hasGather = this->m_hasScatter = true;
|
||||
}
|
||||
else if (!strcasecmp(isa, "generic-1")) {
|
||||
else if (!strcasecmp(isa, "generic-1") ||
|
||||
!strcasecmp(isa, "generic-x1")) {
|
||||
this->m_isa = Target::GENERIC;
|
||||
this->m_nativeVectorWidth = 1;
|
||||
this->m_vectorWidth = 1;
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "avx") || !strcasecmp(isa, "avx1")) {
|
||||
else if (!strcasecmp(isa, "avx") ||
|
||||
!strcasecmp(isa, "avx1") ||
|
||||
!strcasecmp(isa, "avx1-i32x8")) {
|
||||
this->m_isa = Target::AVX;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -397,7 +410,9 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "avx-x2") || !strcasecmp(isa, "avx1-x2")) {
|
||||
else if (!strcasecmp(isa, "avx-x2") ||
|
||||
!strcasecmp(isa, "avx1-x2") ||
|
||||
!strcasecmp(isa, "avx1-i32x16")) {
|
||||
this->m_isa = Target::AVX;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 16;
|
||||
@@ -405,7 +420,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 32;
|
||||
}
|
||||
else if (!strcasecmp(isa, "avx1.1")) {
|
||||
else if (!strcasecmp(isa, "avx1.1") ||
|
||||
!strcasecmp(isa, "avx1.1-i32x8")) {
|
||||
this->m_isa = Target::AVX11;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -418,7 +434,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasRand = true;
|
||||
#endif
|
||||
}
|
||||
else if (!strcasecmp(isa, "avx1.1-x2")) {
|
||||
else if (!strcasecmp(isa, "avx1.1-x2") ||
|
||||
!strcasecmp(isa, "avx1.1-i32x16")) {
|
||||
this->m_isa = Target::AVX11;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 16;
|
||||
@@ -431,7 +448,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasRand = true;
|
||||
#endif
|
||||
}
|
||||
else if (!strcasecmp(isa, "avx2")) {
|
||||
else if (!strcasecmp(isa, "avx2") ||
|
||||
!strcasecmp(isa, "avx2-i32x8")) {
|
||||
this->m_isa = Target::AVX2;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -449,7 +467,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_hasGather = true;
|
||||
#endif
|
||||
}
|
||||
else if (!strcasecmp(isa, "avx2-x2")) {
|
||||
else if (!strcasecmp(isa, "avx2-x2") ||
|
||||
!strcasecmp(isa, "avx2-i32x16")) {
|
||||
this->m_isa = Target::AVX2;
|
||||
this->m_nativeVectorWidth = 16;
|
||||
this->m_vectorWidth = 16;
|
||||
@@ -468,7 +487,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
#endif
|
||||
}
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
else if (!strcasecmp(isa, "neon-8")) {
|
||||
else if (!strcasecmp(isa, "neon-i8x16")) {
|
||||
this->m_isa = Target::NEON8;
|
||||
this->m_nativeVectorWidth = 16;
|
||||
this->m_vectorWidth = 16;
|
||||
@@ -477,7 +496,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 8;
|
||||
}
|
||||
else if (!strcasecmp(isa, "neon-16")) {
|
||||
else if (!strcasecmp(isa, "neon-i16x8")) {
|
||||
this->m_isa = Target::NEON16;
|
||||
this->m_nativeVectorWidth = 8;
|
||||
this->m_vectorWidth = 8;
|
||||
@@ -486,7 +505,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
this->m_maskingIsFree = false;
|
||||
this->m_maskBitCount = 16;
|
||||
}
|
||||
else if (!strcasecmp(isa, "neon-32") || !strcasecmp(isa, "neon")) {
|
||||
else if (!strcasecmp(isa, "neon") ||
|
||||
!strcasecmp(isa, "neon-i32x4")) {
|
||||
this->m_isa = Target::NEON32;
|
||||
this->m_nativeVectorWidth = 4;
|
||||
this->m_vectorWidth = 4;
|
||||
@@ -497,8 +517,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n",
|
||||
isa, SupportedTargetISAs());
|
||||
Error(SourcePos(), "Target \"%s\" is unknown. Choices are: %s.",
|
||||
isa, SupportedTargets());
|
||||
error = true;
|
||||
}
|
||||
|
||||
@@ -592,7 +612,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||
|
||||
|
||||
std::string
|
||||
Target::SupportedTargetCPUs() {
|
||||
Target::SupportedCPUs() {
|
||||
std::string ret;
|
||||
int count = sizeof(supportedCPUs) / sizeof(supportedCPUs[0]);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@@ -605,7 +625,7 @@ Target::SupportedTargetCPUs() {
|
||||
|
||||
|
||||
const char *
|
||||
Target::SupportedTargetArchs() {
|
||||
Target::SupportedArchs() {
|
||||
return
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
"arm, "
|
||||
@@ -615,14 +635,18 @@ Target::SupportedTargetArchs() {
|
||||
|
||||
|
||||
const char *
|
||||
Target::SupportedTargetISAs() {
|
||||
Target::SupportedTargets() {
|
||||
return
|
||||
#ifdef ISPC_ARM_ENABLED
|
||||
"neon-8, neon-16, neon-32, "
|
||||
"neon-i8x16, neon-16x8, neon-32x4, "
|
||||
#endif
|
||||
"sse2, sse2-x2, sse4, sse4-8, sse4-16, sse4-x2, "
|
||||
"avx, avx-x2, avx1.1, avx1.1-x2, avx2, avx2-x2, "
|
||||
"generic-1, generic-4, generic-8, generic-16, generic-32";
|
||||
"sse2-i32x4, sse2-i32x8, "
|
||||
"sse4-i32x4, sse4-i32x8, sse4-i16x8, sse4-i8x16, "
|
||||
"avx1-i32x8, avx1-i32x16, "
|
||||
"avx1.1-i32x8, avx1.1-i32x16, "
|
||||
"avx2-i32x8, avx2-i32x16, "
|
||||
"generic-x1, generic-x4, generic-x8, generic-x16, "
|
||||
"generic-x32, generic-x64";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user