Merge pull request #134 from miimiz/testink_eemeli

Strategyselector prints
This commit is contained in:
Ari Koivula 2016-05-10 13:27:23 +03:00
commit f6a9d237a3
2 changed files with 144 additions and 5 deletions

View file

@ -25,6 +25,8 @@
#include <string.h>
hardware_flags_t kvz_g_hardware_flags;
hardware_flags_t kvz_g_strategies_in_use;
hardware_flags_t kvz_g_strategies_available;
static void set_hardware_flags(int32_t cpuid);
static void* strategyselector_choose_for(const strategy_list_t * const strategies, const char * const strategy_type);
@ -90,7 +92,115 @@ int kvz_strategyselector_init(int32_t cpuid, uint8_t bitdepth) {
//We can free the structure now, as all strategies are statically set to pointers
if (strategies.allocated) {
free(strategies.strategies);
//Also check what optimizations are available and what are in use
//SIMD optimizations available
bool strategies_available = false;
fprintf(stderr, "Available: ");
if (kvz_g_strategies_available.intel_flags.avx != 0){
fprintf(stderr, "avx(%d) ", kvz_g_strategies_available.intel_flags.avx);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.avx2 != 0){
fprintf(stderr, "avx2(%d) ", kvz_g_strategies_available.intel_flags.avx2);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.mmx != 0) {
fprintf(stderr, "mmx(%d) ", kvz_g_strategies_available.intel_flags.mmx);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.sse != 0) {
fprintf(stderr, "sse(%d) ", kvz_g_strategies_available.intel_flags.sse);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.sse2 != 0) {
fprintf(stderr, "sse2(%d) ", kvz_g_strategies_available.intel_flags.sse2);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.sse3 != 0) {
fprintf(stderr, "sse3(%d) ", kvz_g_strategies_available.intel_flags.sse3);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.sse41 != 0) {
fprintf(stderr, "sse41(%d) ", kvz_g_strategies_available.intel_flags.sse41);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.sse42 != 0) {
fprintf(stderr, "sse42(%d) ", kvz_g_strategies_available.intel_flags.sse42);
strategies_available = true;
}
if (kvz_g_strategies_available.intel_flags.ssse3 != 0) {
fprintf(stderr, "ssse3(%d) ", kvz_g_strategies_available.intel_flags.ssse3);
strategies_available = true;
}
if (kvz_g_strategies_available.arm_flags.neon != 0) {
fprintf(stderr, "neon(%d) ", kvz_g_strategies_available.arm_flags.neon);
strategies_available = true;
}
if (kvz_g_strategies_available.powerpc_flags.altivec != 0) {
fprintf(stderr, "altivec(%d) ", kvz_g_strategies_available.powerpc_flags.altivec);
strategies_available = true;
}
//If there is no strategies available
if (!strategies_available){
fprintf(stderr, "no SIMD optimizations");
}
fprintf(stderr, "\n");
//SIMD optimizations in use
bool strategies_in_use = false;
fprintf(stderr, "In use: ");
if (kvz_g_strategies_in_use.intel_flags.avx != 0){
fprintf(stderr, "avx(%d) ", kvz_g_strategies_in_use.intel_flags.avx);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.avx2 != 0){
fprintf(stderr, "avx2(%d) ", kvz_g_strategies_in_use.intel_flags.avx2);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.mmx != 0) {
fprintf(stderr, "mmx(%d) ", kvz_g_strategies_in_use.intel_flags.mmx);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.sse != 0) {
fprintf(stderr, "sse(%d) ", kvz_g_strategies_in_use.intel_flags.sse);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.sse2 != 0) {
fprintf(stderr, "sse2(%d) ", kvz_g_strategies_in_use.intel_flags.sse2);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.sse3 != 0) {
fprintf(stderr, "sse3(%d) ", kvz_g_strategies_in_use.intel_flags.sse3);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.sse41 != 0) {
fprintf(stderr, "sse41(%d) ", kvz_g_strategies_in_use.intel_flags.sse41);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.sse42 != 0) {
fprintf(stderr, "sse42(%d) ", kvz_g_strategies_in_use.intel_flags.sse42);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.intel_flags.ssse3 != 0) {
fprintf(stderr, "ssse3(%d) ", kvz_g_strategies_in_use.intel_flags.ssse3);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.arm_flags.neon != 0) {
fprintf(stderr, "neon(%d) ", kvz_g_strategies_in_use.arm_flags.neon);
strategies_in_use = true;
}
if (kvz_g_strategies_in_use.powerpc_flags.altivec != 0) {
fprintf(stderr, "altivec(%d) ", kvz_g_strategies_in_use.powerpc_flags.altivec);
strategies_in_use = true;
}
//If there is no strategies in use
if (!strategies_in_use){
fprintf(stderr, "no SIMD optimizations");
}
fprintf(stderr, "\n");
//Free memory
free(strategies.strategies);
}
return 1;
@ -117,6 +227,21 @@ int kvz_strategyselector_register(void * const opaque, const char * const type,
new_strategy->priority = priority;
new_strategy->fptr = fptr;
}
//Check what strategies are available when they are registered
if (strcmp(strategy_name, "avx") == 0) kvz_g_strategies_available.intel_flags.avx++;
if (strcmp(strategy_name, "x86_asm_avx") == 0) kvz_g_strategies_available.intel_flags.avx++;
if (strcmp(strategy_name, "avx2") == 0) kvz_g_strategies_available.intel_flags.avx2++;
if (strcmp(strategy_name, "mmx") == 0) kvz_g_strategies_available.intel_flags.mmx++;
if (strcmp(strategy_name, "sse") == 0) kvz_g_strategies_available.intel_flags.sse++;
if (strcmp(strategy_name, "sse2") == 0) kvz_g_strategies_available.intel_flags.sse2++;
if (strcmp(strategy_name, "sse3") == 0) kvz_g_strategies_available.intel_flags.sse3++;
if (strcmp(strategy_name, "sse41") == 0) kvz_g_strategies_available.intel_flags.sse41++;
if (strcmp(strategy_name, "sse42") == 0) kvz_g_strategies_available.intel_flags.sse42++;
if (strcmp(strategy_name, "ssse3") == 0) kvz_g_strategies_available.intel_flags.ssse3++;
if (strcmp(strategy_name, "altivec") == 0) kvz_g_strategies_available.powerpc_flags.altivec++;
if (strcmp(strategy_name, "neon") == 0) kvz_g_strategies_available.arm_flags.neon++;
#ifdef DEBUG_STRATEGYSELECTOR
fprintf(stderr, "Registered strategy %s:%s with priority %d (%p)\n", type, strategy_name, priority, fptr);
#endif //DEBUG_STRATEGYSELECTOR
@ -175,6 +300,20 @@ static void* strategyselector_choose_for(const strategy_list_t * const strategie
return NULL;
}
//Check what strategy we are going to use
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "avx") == 0) kvz_g_strategies_in_use.intel_flags.avx++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "x86_asm_avx") == 0) kvz_g_strategies_available.intel_flags.avx++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "avx2") == 0) kvz_g_strategies_in_use.intel_flags.avx2++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "mmx") == 0) kvz_g_strategies_in_use.intel_flags.mmx++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "sse") == 0) kvz_g_strategies_in_use.intel_flags.sse++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "sse2") == 0) kvz_g_strategies_in_use.intel_flags.sse2++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "sse3") == 0) kvz_g_strategies_in_use.intel_flags.sse3++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "sse41") == 0) kvz_g_strategies_in_use.intel_flags.sse41++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "sse42") == 0) kvz_g_strategies_in_use.intel_flags.sse42++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "ssse3") == 0) kvz_g_strategies_in_use.intel_flags.ssse3++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "altivec") == 0) kvz_g_strategies_in_use.powerpc_flags.altivec++;
if (strcmp(strategies->strategies[max_priority_i].strategy_name, "neon") == 0) kvz_g_strategies_in_use.arm_flags.neon++;
return strategies->strategies[max_priority_i].fptr;
}
@ -369,7 +508,6 @@ static void set_hardware_flags(int32_t cpuid) {
if (kvz_g_hardware_flags.intel_flags.avx) fprintf(stderr, " AVX");
if (kvz_g_hardware_flags.intel_flags.avx2) fprintf(stderr, " AVX2");
fprintf(stderr, "\n");
#endif //COMPILE_INTEL
#if COMPILE_POWERPC

View file

@ -41,7 +41,7 @@ typedef struct {
typedef struct {
unsigned int count;
unsigned int allocated;
unsigned int allocated;//How much memory is allocated
strategy_t* strategies;
} strategy_list_t;
@ -75,7 +75,8 @@ typedef struct {
} hardware_flags_t;
extern hardware_flags_t kvz_g_hardware_flags;
extern hardware_flags_t kvz_g_strategies_in_use;
extern hardware_flags_t kvz_g_strategies_available;
int kvz_strategyselector_init(int32_t cpuid, uint8_t bitdepth);
int kvz_strategyselector_register(void *opaque, const char *type, const char *strategy_name, int priority, void *fptr);