Skip to content

Commit

Permalink
Init Sandybridge codes based on Nehalem.
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyi committed Mar 30, 2012
1 parent 5cbbc49 commit 19a48b8
Show file tree
Hide file tree
Showing 57 changed files with 309 additions and 45 deletions.
5 changes: 3 additions & 2 deletions Makefile.system
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ endif
ifdef DYNAMIC_ARCH
ifeq ($(ARCH), x86)
DYNAMIC_CORE = KATMAI COPPERMINE NORTHWOOD PRESCOTT BANIAS \
CORE2 PENRYN DUNNINGTON NEHALEM ATHLON OPTERON OPTERON_SSE3 BARCELONA ATOM NANO
CORE2 PENRYN DUNNINGTON NEHALEM SANDYBRIDGE ATHLON OPTERON OPTERON_SSE3 BARCELONA ATOM NANO
endif

ifeq ($(ARCH), x86_64)
DYNAMIC_CORE = PRESCOTT CORE2 PENRYN DUNNINGTON NEHALEM OPTERON OPTERON_SSE3 BARCELONA ATOM NANO
DYNAMIC_CORE = PRESCOTT CORE2 PENRYN DUNNINGTON NEHALEM SANDYBRIDGE OPTERON OPTERON_SSE3 BARCELONA ATOM NANO
endif

ifndef DYNAMIC_CORE
Expand Down Expand Up @@ -740,6 +740,7 @@ export HAVE_SSE4_1
export HAVE_SSE4_2
export HAVE_SSE4A
export HAVE_SSE5
export HAVE_AVX
export KERNELDIR
export FUNCTION_PROFILE
export TARGET_CORE
Expand Down
2 changes: 2 additions & 0 deletions TargetList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CORE2
PENRYN
DUNNINGTON
NEHALEM
SANDYBRIDGE
ATOM

b)AMD CPU:
Expand Down Expand Up @@ -47,6 +48,7 @@ CELL
3.MIPS64 CPU:
SICORTEX
LOONGSON3A
LOONGSON3B

4.IA64 CPU:
ITANIUM2
Expand Down
3 changes: 3 additions & 0 deletions cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#define CORE_NEHALEM 17
#define CORE_ATOM 18
#define CORE_NANO 19
#define CORE_SANDYBRIDGE 20

#define HAVE_SSE (1 << 0)
#define HAVE_SSE2 (1 << 1)
Expand All @@ -122,6 +123,7 @@
#define HAVE_MISALIGNSSE (1 << 15)
#define HAVE_128BITFPU (1 << 16)
#define HAVE_FASTMOVU (1 << 17)
#define HAVE_AVX (1 << 18)

#define CACHE_INFO_L1_I 1
#define CACHE_INFO_L1_D 2
Expand Down Expand Up @@ -188,4 +190,5 @@ typedef struct {
#define CPUTYPE_NSGEODE 41
#define CPUTYPE_VIAC3 42
#define CPUTYPE_NANO 43
#define CPUTYPE_SANDYBRIDGE 44
#endif
11 changes: 9 additions & 2 deletions cpuid_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ int get_cputype(int gettype){
if ((ecx & (1 << 9)) != 0) feature |= HAVE_SSSE3;
if ((ecx & (1 << 19)) != 0) feature |= HAVE_SSE4_1;
if ((ecx & (1 << 20)) != 0) feature |= HAVE_SSE4_2;
if ((ecx & (1 << 28)) != 0) feature |= HAVE_AVX;

if (have_excpuid() >= 0x01) {
cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
Expand Down Expand Up @@ -983,7 +984,7 @@ int get_cpuname(void){
return CPUTYPE_NEHALEM;
case 10:
//Intel Core i5-2000 /i7-2000 (Sandy Bridge)
return CPUTYPE_NEHALEM;
return CPUTYPE_SANDYBRIDGE;
case 12:
//Xeon Processor 5600 (Westmere-EP)
return CPUTYPE_NEHALEM;
Expand Down Expand Up @@ -1140,6 +1141,7 @@ static char *cpuname[] = {
"NSGEODE",
"VIAC3",
"NANO",
"SANDYBRIDGE",
};

static char *lowercpuname[] = {
Expand Down Expand Up @@ -1186,6 +1188,7 @@ static char *lowercpuname[] = {
"tms3x00",
"nsgeode",
"nano",
"sandybridge",
};

static char *corename[] = {
Expand All @@ -1209,6 +1212,7 @@ static char *corename[] = {
"NEHALEM",
"ATOM",
"NANO",
"SANDYBRIDGE",
};

static char *corename_lower[] = {
Expand All @@ -1232,6 +1236,7 @@ static char *corename_lower[] = {
"nehalem",
"atom",
"nano",
"sandybridge",
};


Expand Down Expand Up @@ -1315,7 +1320,7 @@ int get_coretype(void){
return CORE_NEHALEM;
case 10:
//Intel Core i5-2000 /i7-2000 (Sandy Bridge)
return CORE_NEHALEM;
return CORE_SANDYBRIDGE;
case 12:
//Xeon Processor 5600 (Westmere-EP)
return CORE_NEHALEM;
Expand Down Expand Up @@ -1414,6 +1419,7 @@ void get_cpuconfig(void){
if (features & HAVE_SSE4_2) printf("#define HAVE_SSE4_2\n");
if (features & HAVE_SSE4A) printf("#define HAVE_SSE4A\n");
if (features & HAVE_SSE5 ) printf("#define HAVE_SSSE5\n");
if (features & HAVE_AVX ) printf("#define HAVE_AVX\n");
if (features & HAVE_3DNOWEX) printf("#define HAVE_3DNOWEX\n");
if (features & HAVE_3DNOW) printf("#define HAVE_3DNOW\n");
if (features & HAVE_CFLUSH) printf("#define HAVE_CFLUSH\n");
Expand Down Expand Up @@ -1479,6 +1485,7 @@ void get_sse(void){
if (features & HAVE_SSE4_2) printf("HAVE_SSE4_2=1\n");
if (features & HAVE_SSE4A) printf("HAVE_SSE4A=1\n");
if (features & HAVE_SSE5 ) printf("HAVE_SSSE5=1\n");
if (features & HAVE_AVX ) printf("HAVE_AVX=1\n");
if (features & HAVE_3DNOWEX) printf("HAVE_3DNOWEX=1\n");
if (features & HAVE_3DNOW) printf("HAVE_3DNOW=1\n");

Expand Down
13 changes: 12 additions & 1 deletion driver/others/parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ int get_L2_size(void){

#if defined(ATHLON) || defined(OPTERON) || defined(BARCELONA) || \
defined(CORE_PRESCOTT) || defined(CORE_CORE2) || defined(PENRYN) || defined(DUNNINGTON) || \
defined(CORE_NEHALEM) || defined(ATOM) || defined(GENERIC)
defined(CORE_NEHALEM) || defined(CORE_SANDYBRIDGE) || defined(ATOM) || defined(GENERIC)

cpuid(0x80000006, &eax, &ebx, &ecx, &edx);

Expand Down Expand Up @@ -384,6 +384,17 @@ void blas_set_parameter(void){
#endif
#endif

#if defined(SANDYBRIDGE)
sgemm_p = 1024;
dgemm_p = 512;
cgemm_p = 512;
zgemm_p = 256;
#ifdef EXPRECISION
qgemm_p = 256;
xgemm_p = 128;
#endif
#endif

#if defined(CORE_PRESCOTT) || defined(GENERIC)
size >>= 6;

Expand Down
14 changes: 14 additions & 0 deletions getarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define CORENAME "NEHALEM"
#endif

#ifdef FORCE_SANDYBRIDGE
#define FORCE
#define FORCE_INTEL
#define ARCHITECTURE "X86"
#define SUBARCHITECTURE "SANDYBRIDGE"
#define ARCHCONFIG "-DSANDYBRIDGE " \
"-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
"-DL2_SIZE=262144 -DL2_LINESIZE=64 " \
"-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
"-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 -DHAVE_AVX"
#define LIBNAME "sandybridge"
#define CORENAME "SANDYBRIDGE"
#endif

#ifdef FORCE_ATOM
#define FORCE
#define FORCE_INTEL
Expand Down
16 changes: 16 additions & 0 deletions kernel/setparam-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,22 @@ static void init_parameter(void) {
#endif
#endif

#ifdef SANDYBRIDGE

#ifdef DEBUG
fprintf(stderr, "Sandybridge\n");
#endif

TABLE_NAME.sgemm_p = SGEMM_DEFAULT_P;
TABLE_NAME.dgemm_p = DGEMM_DEFAULT_P;
TABLE_NAME.cgemm_p = CGEMM_DEFAULT_P;
TABLE_NAME.zgemm_p = ZGEMM_DEFAULT_P;
#ifdef EXPRECISION
TABLE_NAME.qgemm_p = QGEMM_DEFAULT_P;
TABLE_NAME.xgemm_p = XGEMM_DEFAULT_P;
#endif
#endif

#ifdef OPTERON

#ifdef DEBUG
Expand Down
1 change: 1 addition & 0 deletions kernel/x86/KERNEL.SANDYBRIDGE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(KERNELDIR)/KERNEL.PENRYN
6 changes: 6 additions & 0 deletions kernel/x86/gemm_kernel_2x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
#define PREFETCHB prefetcht0
#endif

#ifdef SANDYBRIDGE
#define PREFETCHSIZE (8 * 1 - 4)
#define PREFETCHW prefetcht0
#define PREFETCHB prefetcht0
#endif

#ifndef PREFETCH
#define PREFETCH prefetcht0
#endif
Expand Down
8 changes: 7 additions & 1 deletion kernel/x86/gemm_kernel_4x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
#define PREFETCHB prefetcht0
#endif

#ifdef SANDYBRIDGE
#define PREFETCHSIZE (16 * 1 - 8)
#define PREFETCHW prefetcht0
#define PREFETCHB prefetcht0
#endif

#ifndef PREFETCH
#define PREFETCH prefetcht0
#endif
Expand Down Expand Up @@ -262,7 +268,7 @@
movaps -16 * SIZE(AA), %xmm0

addps %xmm2, %xmm7
#ifndef NEHALEM
#if !(defined(NEHALEM) || defined(SANDYBRIDGE))
PREFETCH (PREFETCHSIZE + 16) * SIZE(AA)
#endif
pshufd $0x93, %xmm1, %xmm2
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/gemv_n_sse.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define PREFETCHSIZE (16 * 4)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (16 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/gemv_n_sse2.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define PREFETCHSIZE (8 * 2)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (8 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/gemv_t_sse.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define PREFETCHSIZE (16 * 4)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (16 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/gemv_t_sse2.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define PREFETCHSIZE (8 * 2)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (8 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/trsm_kernel_LN_2x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define PREFETCHSIZE (8 * 21 + 4)
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHSIZE (8 * 21 + 4)
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/trsm_kernel_LN_4x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define PREFETCHSIZE (8 * 21 + 4)
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHSIZE (8 * 21 + 4)
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/trsm_kernel_LT_2x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define PREFETCHSIZE (8 * 21 + 4)
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHSIZE (8 * 21 + 4)
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/trsm_kernel_LT_4x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define PREFETCHSIZE (8 * 21 + 4)
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHSIZE (8 * 21 + 4)
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/trsm_kernel_RT_2x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define PREFETCHSIZE (8 * 21 + 4)
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHSIZE (8 * 21 + 4)
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/trsm_kernel_RT_4x4_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define PREFETCHSIZE (8 * 21 + 4)
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHSIZE (8 * 21 + 4)
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/zgemm_kernel_1x2_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#define PREFETCHB prefetcht0
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCHSIZE (8 * 1 - 4)
#define PREFETCHW prefetcht0
#define PREFETCHB prefetcht0
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/zgemm_kernel_2x2_penryn.S
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#define PREFETCHB prefetcht0
#endif

#ifdef NEHALEM
#if defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCHSIZE (16 * 1 + 8)
#define PREFETCHW prefetcht0
#define PREFETCHB prefetcht0
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/zgemv_n_sse.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define PREFETCHSIZE (16 * 2)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (16 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/zgemv_n_sse2.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define PREFETCHSIZE (8 * 2)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (8 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/zgemv_t_sse.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define PREFETCHSIZE (16 * 2)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (16 * 7)
Expand Down
2 changes: 1 addition & 1 deletion kernel/x86/zgemv_t_sse2.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define PREFETCHSIZE (8 * 2)
#endif

#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM)
#if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
#define PREFETCH prefetcht0
#define PREFETCHW prefetcht0
#define PREFETCHSIZE (8 * 7)
Expand Down
Loading

0 comments on commit 19a48b8

Please sign in to comment.