diff --git a/chapters/chapter2/pi/v6/Makefile b/chapters/chapter2/pi/v6/Makefile index b059cfbebc19ab96e3e787fbd6bfe9614f46f1c7..9f63165b1f85404a10a9d9e08944ffda4a160c20 100644 --- a/chapters/chapter2/pi/v6/Makefile +++ b/chapters/chapter2/pi/v6/Makefile @@ -5,13 +5,13 @@ CXX = g++ RM = rm -rf ASM = nasm ifeq ($(UNAME), Darwin) -#CFLAGS = -Wall -O3 -march=native -mtune=native -CFLAGS = -Wall -O0 -g +#CFLAGS = -Wall -std=c11 -O3 -march=native -mtune=native +CFLAGS = -Wall -std=c11 -O0 -g ASMFLAGS = -f macho64 -O0 -g --prefix _ LDFLAGS = else -#CFLAGS = -Wall -O3 -g -march=native -mtune=native -mfpmath=sse,387 -CFLAGS = -Wall -O0 -g +#CFLAGS = -Wall -std=c11 -O3 -g -march=native -mtune=native -mfpmath=sse,387 +CFLAGS = -Wall -std=c11 -O0 -g ASMFLAGS = -f elf64 -O0 -g -F dwarf LDFLAGS = endif diff --git a/chapters/chapter2/pi/v6/main.c b/chapters/chapter2/pi/v6/main.c index 7f12642e24388da40031cc9f20684642c2f4512e..1a09b167db6fbf0a2e1766364a24c8d8f4c781ef 100644 --- a/chapters/chapter2/pi/v6/main.c +++ b/chapters/chapter2/pi/v6/main.c @@ -1,17 +1,18 @@ #include <emmintrin.h> +#include <stdalign.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> -double step __attribute__ ((aligned(32))); -double sum __attribute__ ((aligned(32))); -long long num_steps __attribute__ ((aligned(32))) = 1000000; +alignas(32) double step; +alignas(32) double sum; +alignas(32) long long num_steps = 1000000; -double four[] __attribute__ ((aligned(32))) = {4.0, 4.0, 4.0, 4.0}; -double two[] __attribute__ ((aligned(32))) = {2.0, 2.0, 2.0, 2.0}; -double one[] __attribute__ ((aligned(32))) = {1.0, 1.0, 1.0, 1.0}; -double ofs[] __attribute__ ((aligned(32))) = {0.5, 1.5, 2.5, 3.5}; +alignas(32) double four[] = {4.0, 4.0, 4.0, 4.0}; +alignas(32) double two[] = {2.0, 2.0, 2.0, 2.0}; +alignas(32) double one[] = {1.0, 1.0, 1.0, 1.0}; +alignas(32) double ofs[] = {0.5, 1.5, 2.5, 3.5}; void calcPi(void) { diff --git a/chapters/chapter2/pi/v7/Makefile b/chapters/chapter2/pi/v7/Makefile index 4e9f20c766611b9cd84deee8be6bc3a38dd1cef8..c4f1e4cd5eb24058cf676e176dbe847a1f626fba 100644 --- a/chapters/chapter2/pi/v7/Makefile +++ b/chapters/chapter2/pi/v7/Makefile @@ -3,11 +3,11 @@ MAKE = make CC = gcc CXX = g++ ifeq ($(UNAME), Darwin) -CFLAGS = -Wall -O3 -g -march=native -mtune=native -pthread +CFLAGS = -Wall -std=c11 -O3 -g -march=native -mtune=native -pthread ASMFLAGS = -f macho64 -O0 -g --prefix _ LDFLAGS = else -CFLAGS = -Wall -O3 -g -march=native -mtune=native -mfpmath=sse,387 -pthread +CFLAGS = -Wall -std=c11 -O3 -g -march=native -mtune=native -mfpmath=sse,387 -pthread ASMFLAGS = -f elf64 -O0 -g -F dwarf LDFLAGS = endif diff --git a/chapters/chapter2/pi/v7/main.c b/chapters/chapter2/pi/v7/main.c index 1dd747324bf5ec966a681bd353334c7e98fa81ac..d52930d59ff65b7298aacf77b5a37cb351ae12c3 100644 --- a/chapters/chapter2/pi/v7/main.c +++ b/chapters/chapter2/pi/v7/main.c @@ -1,3 +1,4 @@ +#include <stdalign.h> #include <stdio.h> #include <stdlib.h> #include <pthread.h> @@ -5,10 +6,10 @@ #define MAX_THREADS 2 -double four[] __attribute__ ((aligned(16))) = {4.0, 4.0}; -double two[] __attribute__ ((aligned(16))) = {2.0, 2.0}; -double one[] __attribute__ ((aligned(16))) = {1.0, 1.0}; -double ofs[] __attribute__ ((aligned(16))) = {0.5, 1.5}; +alignas(16) double four[] = {4.0, 4.0}; +alignas(16) double two[] = {2.0, 2.0}; +alignas(16) double one[] = {1.0, 1.0}; +alignas(16) double ofs[] = {0.5, 1.5}; long long num_steps = 1000000; double step;