Skip to content

Commit 4f8c55c

Browse files
Yuanhan Liuneilbrown
authored andcommitted
lib/raid6: build proper files on corresponding arch
sse and avx2 stuff only exist on x86 arch, and we don't need to build altivec on x86. And we can do that at lib/raid6/Makefile. Proposed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
1 parent 2c93584 commit 4f8c55c

8 files changed

Lines changed: 28 additions & 27 deletions

File tree

‎lib/raid6/Makefile‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
obj-$(CONFIG_RAID6_PQ) += raid6_pq.o
22

3-
raid6_pq-y += algos.o recov.o recov_ssse3.o recov_avx2.o tables.o int1.o int2.o int4.o \
4-
int8.o int16.o int32.o altivec1.o altivec2.o altivec4.o \
5-
altivec8.o mmx.o sse1.o sse2.o avx2.o
3+
raid6_pq-y += algos.o recov.o tables.o int1.o int2.o int4.o \
4+
int8.o int16.o int32.o
5+
6+
raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o
7+
raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o
8+
69
hostprogs-y += mktables
710

811
quiet_cmd_unroll = UNROLL $@

‎lib/raid6/altivec.uc‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424

2525
#include <linux/raid/pq.h>
2626

27-
#ifdef CONFIG_ALTIVEC
28-
2927
#include <altivec.h>
3028
#ifdef __KERNEL__
3129
# include <asm/cputable.h>
3230
# include <asm/switch_to.h>
33-
#endif
3431

3532
/*
3633
* This is the C data type to use. We use a vector of

‎lib/raid6/mmx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* MMX implementation of RAID-6 syndrome functions
1717
*/
1818

19-
#if defined(__i386__) && !defined(__arch_um__)
19+
#ifdef CONFIG_X86_32
2020

2121
#include <linux/raid/pq.h>
2222
#include "x86.h"

‎lib/raid6/recov_avx2.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* of the License.
99
*/
1010

11-
#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)
12-
1311
#if CONFIG_AS_AVX2
1412

1513
#include <linux/raid/pq.h>
@@ -323,5 +321,3 @@ const struct raid6_recov_calls raid6_recov_avx2 = {
323321
#else
324322
#warning "your version of binutils lacks AVX2 support"
325323
#endif
326-
327-
#endif

‎lib/raid6/recov_ssse3.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* of the License.
88
*/
99

10-
#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)
11-
1210
#include <linux/raid/pq.h>
1311
#include "x86.h"
1412

@@ -332,5 +330,3 @@ const struct raid6_recov_calls raid6_recov_ssse3 = {
332330
#endif
333331
.priority = 1,
334332
};
335-
336-
#endif

‎lib/raid6/sse1.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* worthwhile as a separate implementation.
2222
*/
2323

24-
#if defined(__i386__) && !defined(__arch_um__)
24+
#ifdef CONFIG_X86_32
2525

2626
#include <linux/raid/pq.h>
2727
#include "x86.h"

‎lib/raid6/sse2.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*
1818
*/
1919

20-
#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)
21-
2220
#include <linux/raid/pq.h>
2321
#include "x86.h"
2422

@@ -159,9 +157,7 @@ const struct raid6_calls raid6_sse2x2 = {
159157
1 /* Has cache hints */
160158
};
161159

162-
#endif
163-
164-
#if defined(__x86_64__) && !defined(__arch_um__)
160+
#ifdef CONFIG_X86_64
165161

166162
/*
167163
* Unrolled-by-4 SSE2 implementation
@@ -259,4 +255,4 @@ const struct raid6_calls raid6_sse2x4 = {
259255
1 /* Has cache hints */
260256
};
261257

262-
#endif
258+
#endif /* CONFIG_X86_64 */

‎lib/raid6/test/Makefile‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,31 @@ LD = ld
1010
AWK = awk -f
1111
AR = ar
1212
RANLIB = ranlib
13+
OBJS = int1.o int2.o int4.o int8.o int16.o int32.o recov.o algos.o tables.o
1314

1415
ARCH := $(shell uname -m 2>/dev/null | sed -e /s/i.86/i386/)
1516
ifeq ($(ARCH),i386)
1617
CFLAGS += -DCONFIG_X86_32
18+
IS_X86 = yes
1719
endif
1820
ifeq ($(ARCH),x86_64)
1921
CFLAGS += -DCONFIG_X86_64
22+
IS_X86 = yes
23+
endif
24+
25+
ifeq ($(IS_X86),yes)
26+
OBJS += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o
27+
CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1" | \
28+
gcc -c -x assembler - >&/dev/null && \
29+
rm ./-.o && echo -DCONFIG_AS_AVX2=1)
30+
else
31+
HAS_ALTIVEC := $(shell echo -e '\#include <altivec.h>\nvector int a;' |\
32+
gcc -c -x c - >&/dev/null && \
33+
rm ./-.o && echo yes)
34+
ifeq ($(HAS_ALTIVEC),yes)
35+
OBJS += altivec1.o altivec2.o altivec4.o altivec8.o
36+
endif
2037
endif
21-
CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1"| gcc -c -x assembler - &&\
22-
rm ./-.o && echo -DCONFIG_AS_AVX2=1)
2338

2439
.c.o:
2540
$(CC) $(CFLAGS) -c -o $@ $<
@@ -32,9 +47,7 @@ CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1"| gcc -c -x assembler - &&\
3247

3348
all: raid6.a raid6test
3449

35-
raid6.a: int1.o int2.o int4.o int8.o int16.o int32.o mmx.o sse1.o sse2.o avx2.o \
36-
altivec1.o altivec2.o altivec4.o altivec8.o recov.o recov_ssse3.o recov_avx2.o algos.o \
37-
tables.o
50+
raid6.a: $(OBJS)
3851
rm -f $@
3952
$(AR) cq $@ $^
4053
$(RANLIB) $@

0 commit comments

Comments
 (0)