Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Commit

Permalink
t1ha: minor fix for Intel Compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
erthink committed Sep 15, 2018
1 parent 9fab0af commit 20bdd33
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 16 deletions.
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
# So, define it to 0 for calmness if doubt.
T1HA_USE_FAST_ONESHOT_READ ?=1

# To use the Intel compiler you need something like this
#CC=/opt/intel/compilers_and_libraries/linux/bin/intel64/icc
#CXX=/opt/intel/compilers_and_libraries/linux/bin/intel64/icc
#LD=/opt/intel/compilers_and_libraries/linux/bin/intel64/xild
#AR=/opt/intel/compilers_and_libraries/linux/bin/intel64/xiar
#TARGET_ARCH_ia32=yes

CC ?= gcc
CXX ?= g++

CFLAGS ?= -std=c99 -O3 -DNDEBUG -D_DEFAULT_SOURCE -fno-stack-protector
CXXFLAGS = -std=c++11 $(filter-out -std=c99,$(CFLAGS))

TARGET_ARCH_e2k = $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i 'e2k' && echo yes || echo no))
TARGET_ARCH_ia32 = $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i -e '^Target: \(x86_64\)\|\([iI][3-6]86\)-.*' && echo yes || echo no))
TARGET_ARCH_ppc = $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i -e '^Target: powerpc.*' && echo yes || echo no))
TARGET_ARCH_e2k ?= $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i 'e2k' && echo yes || echo no))
TARGET_ARCH_ia32 ?= $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i -e '^Target: \(x86_64\)\|\([iI][3-6]86\)-.*' && echo yes || echo no))
TARGET_ARCH_ppc ?= $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i -e '^Target: powerpc.*' && echo yes || echo no))

OBJ_LIST := t1ha0.o t1ha1.o t1ha2.o
BENCH_EXTRA := bench.o mera.o test.o 4bench_xxhash.o 4bench_highwayhash_test.o 4bench_highwayhash_pure_c.o 4bench_highwayhash_portable.o
Expand Down
6 changes: 0 additions & 6 deletions tests/highwayhash/pure_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ This code is compatible with C90 with the additional requirement of
supporting uint64_t.
*/

/*////////////////////////////////////////////////////////////////////////////*/
/* Internal implementation */
/*////////////////////////////////////////////////////////////////////////////*/

void HighwayHashReset_pure_c(const uint64_t key[4], HighwayHashState *state) {
state->mul0[0] = 0xdbe6d5d5fe4cce2full;
Expand Down Expand Up @@ -169,9 +167,7 @@ static void HighwayHashFinalize256_pure_c(HighwayHashState *state,
&hash[3], &hash[2]);
}

/*////////////////////////////////////////////////////////////////////////////*/
/* Non-cat API: single call on full data */
/*////////////////////////////////////////////////////////////////////////////*/

static void ProcessAll(const uint8_t *data, size_t size, const uint64_t key[4],
HighwayHashState *state) {
Expand Down Expand Up @@ -205,9 +201,7 @@ void HighwayHash256_pure_c(const uint64_t key[4], const uint8_t *data,
HighwayHashFinalize256_pure_c(&state, hash);
}

/*////////////////////////////////////////////////////////////////////////////*/
/* Cat API: allows appending with multiple calls */
/*////////////////////////////////////////////////////////////////////////////*/

void HighwayHashCatStart_pure_c(const uint64_t key[4], HighwayHashCat *state) {
HighwayHashReset_pure_c(key, &state->state);
Expand Down
6 changes: 0 additions & 6 deletions tests/highwayhash/pure_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
extern "C" {
#endif

/*////////////////////////////////////////////////////////////////////////////*/
/* Low-level API, use for implementing streams etc... */
/*////////////////////////////////////////////////////////////////////////////*/

typedef struct {
uint64_t v0[4];
Expand All @@ -36,9 +34,7 @@ static void HighwayHashFinalize128_pure_c(HighwayHashState *state,
static void HighwayHashFinalize256_pure_c(HighwayHashState *state,
uint64_t hash[4]);

/*////////////////////////////////////////////////////////////////////////////*/
/* Non-cat API: single call on full data */
/*////////////////////////////////////////////////////////////////////////////*/

uint64_t HighwayHash64_pure_c(const uint64_t key[4], const uint8_t *data,
size_t size);
Expand All @@ -49,9 +45,7 @@ void HighwayHash128_pure_c(const uint64_t key[4], const uint8_t *data,
void HighwayHash256_pure_c(const uint64_t key[4], const uint8_t *data,
size_t size, uint64_t hash[4]);

/*////////////////////////////////////////////////////////////////////////////*/
/* Cat API: allows appending with multiple calls */
/*////////////////////////////////////////////////////////////////////////////*/

typedef struct {
HighwayHashState state;
Expand Down
46 changes: 45 additions & 1 deletion tests/mera.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@
/*****************************************************************************/

/* Compiler's includes for builtins/intrinsics */
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
#if defined(_MSC_VER)
#include <intrin.h>
#elif defined(__INTEL_COMPILER)
#include <ia32intrin.h>
#elif __GNUC_PREREQ(4, 4) || defined(__clang__)
#if defined(__ia32__) || defined(__e2k__)
#include <x86intrin.h>
Expand Down Expand Up @@ -930,6 +932,48 @@ static unsigned clock_rdtsc_finish(timestamp_t *now) {

ia32_cpu_features_t ia32_cpu_features;

/* Crutch for Intel Compiler (copy&paste from GCC's cpuid.h file */
#if defined(__INTEL_COMPILER) && defined(__GNUC__) && !defined(__cpuid)
#define __cpuid(level, a, b, c, d) \
__asm__("cpuid\n\t" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(level))

#define __cpuid_count(level, count, a, b, c, d) \
__asm__("cpuid\n\t" \
: "=a"(a), "=b"(b), "=c"(c), "=d"(d) \
: "0"(level), "2"(count))
static __inline unsigned int __get_cpuid_max(unsigned int __ext,
unsigned int *__sig) {
unsigned int __eax, __ebx, __ecx, __edx;

#ifndef __x86_64__
/* See if we can use cpuid. On AMD64 we always can. */
__asm__("pushf{l|d}\n\t"
"pushf{l|d}\n\t"
"pop{l}\t%0\n\t"
"mov{l}\t{%0, %1|%1, %0}\n\t"
"xor{l}\t{%2, %0|%0, %2}\n\t"
"push{l}\t%0\n\t"
"popf{l|d}\n\t"
"pushf{l|d}\n\t"
"pop{l}\t%0\n\t"
"popf{l|d}\n\t"
: "=&r"(__eax), "=&r"(__ebx)
: "i"(0x00200000));

if (!((__eax ^ __ebx) & 0x00200000))
return 0;
#endif /* __x86_64__ */

/* Host supports cpuid. Return highest supported cpuid input value. */
__cpuid(__ext, __eax, __ebx, __ecx, __edx);

if (__sig)
*__sig = __ebx;

return __eax;
}
#endif /* Crutch for Intel Compiler (copy&paste from GCC's cpuid.h file */

void ia32_fetch_cpu_features(void) {
memset(&ia32_cpu_features, 0, sizeof(ia32_cpu_features));
#ifdef __GNUC__
Expand Down

0 comments on commit 20bdd33

Please sign in to comment.