[Autotest][PATCH 05/12] virt: Add memory stress test to cpu_flags test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



usage:
  ./cpuflags-test --stressmem 100 (in MB)

Signed-off-by: Jiří Župka <jzupka@xxxxxxxxxx>
---
 client/virt/deps/test_cpu_flags/Makefile        |    9 +++++-
 client/virt/deps/test_cpu_flags/cpuflags-test.c |   28 ++++++++++++-------
 client/virt/deps/test_cpu_flags/stressmem.c     |   33 +++++++++++++++++++++++
 client/virt/deps/test_cpu_flags/tests.h         |    1 +
 4 files changed, 58 insertions(+), 13 deletions(-)
 create mode 100644 client/virt/deps/test_cpu_flags/stressmem.c

diff --git a/client/virt/deps/test_cpu_flags/Makefile b/client/virt/deps/test_cpu_flags/Makefile
index b95c36e..1513649 100644
--- a/client/virt/deps/test_cpu_flags/Makefile
+++ b/client/virt/deps/test_cpu_flags/Makefile
@@ -2,7 +2,7 @@ MKDIR = mkdir -p
 
 OPTFLAGS=-O3
 
-CFLAGS= -m64 ${OPTFLAGS} -std=c99 -pipe \
+CFLAGS= ${OPTFLAGS} -std=c99 -pipe \
 	-ftree-vectorize \
 	-ffast-math \
 	-fopenmp \
@@ -51,7 +51,7 @@ default:cpuflags-test
 
 all:cpuflags-test
 
-cpuflags-test: avx.o fma4.o xop.o sse4a.o sse4.o ssse3.o sse3.o aes.o pclmul.o rdrand.o stress.o
+cpuflags-test: avx.o fma4.o xop.o sse4a.o sse4.o ssse3.o sse3.o aes.o pclmul.o rdrand.o stress.o stressmem.o
 	$(CC) $(CFLAGS) $(LIBS) cpuflags-test.c -o cpuflags-test \
 		aes.o \
 		pclmul.o \
@@ -64,6 +64,7 @@ cpuflags-test: avx.o fma4.o xop.o sse4a.o sse4.o ssse3.o sse3.o aes.o pclmul.o r
 		ssse3.o \
 		sse3.o \
 		stress.o \
+		stressmem.o \
 
 aes.o: aes.c tests.h
 	$(CC) $(CFLAGSAES) $(LIBS) -c aes.c
@@ -98,6 +99,10 @@ sse3.o: sse3.c tests.h
 stress.o: stress.c tests.h
 	$(CC) $(CFLAGSSTRESS) $(LIBS) -c stress.c
 
+stressmem.o: stressmem.c tests.h
+	$(CC) $(CFLAGSSTRESS) $(LIBS) -c stressmem.c
+
+
 ARCHIVE= cpuflags-test
 
 tar: clean
diff --git a/client/virt/deps/test_cpu_flags/cpuflags-test.c b/client/virt/deps/test_cpu_flags/cpuflags-test.c
index dd97d61..2e68b26 100644
--- a/client/virt/deps/test_cpu_flags/cpuflags-test.c
+++ b/client/virt/deps/test_cpu_flags/cpuflags-test.c
@@ -14,8 +14,9 @@ void print_help(){
 			"  --pclmul                   test carry less multiplication.\n"
 			"  --rdrand                   test rdrand instruction.\n"
 			"  --fma4                     test fma4 instruction.\n"
-			"  --xop                     test fma4 instruction.\n"
-			"  --stress n_cpus,avx,aes    start stress on n_cpus.and cpuflags\n");
+			"  --xop                      test fma4 instruction.\n"
+			"  --stress n_cpus,avx,aes    start stress on n_cpus.and cpuflags.\n"
+			"  --stressmem mem_size       start stressmem with mem_size.\n");
 }
 
 
@@ -74,6 +75,7 @@ int main(int argc, char **argv) {
 		int option_index = 0;
 		static struct option long_options[] =
 				{{ "stress",required_argument, 0, 0 },
+				{ "stressmem", required_argument, 0, 0 },
 				{ "sse3",   no_argument, 0, 0 },
 				{ "ssse3",  no_argument, 0, 0 },
 				{ "sse4",   no_argument, 0, 0 },
@@ -100,35 +102,39 @@ int main(int argc, char **argv) {
 				stress(parse_Inst(optarg));
 				break;
 			case 1:
-				ret += sse3();
+				stressmem(atoi(optarg));
 				break;
 			case 2:
-				ret += ssse3();
+				ret += sse3();
 				break;
 			case 3:
-				ret += sse4();
+				ret += ssse3();
 				break;
 			case 4:
-				ret += sse4a();
+				ret += sse4();
 				break;
 			case 5:
-				ret += avx();
+				ret += sse4a();
 				break;
 			case 6:
-				ret += aes();
+				ret += avx();
 				break;
 			case 7:
-				ret += pclmul();
+				ret += aes();
 				break;
 			case 8:
-				ret += rdrand();
+				ret += pclmul();
 				break;
 			case 9:
-				ret += fma4();
+				ret += rdrand();
 				break;
 			case 10:
+				ret += fma4();
+				break;
+			case 11:
 				ret += xop();
 				break;
+
 			}
 			break;
 
diff --git a/client/virt/deps/test_cpu_flags/stressmem.c b/client/virt/deps/test_cpu_flags/stressmem.c
new file mode 100644
index 0000000..41a7c06
--- /dev/null
+++ b/client/virt/deps/test_cpu_flags/stressmem.c
@@ -0,0 +1,33 @@
+/*
+ * stress.c
+ *
+ *  Created on: Nov 29, 2011
+ *      Author: jzupka
+ */
+
+#include "tests.h"
+
+typedef float vector_type;//
+
+void stressmem(unsigned int sizeMB) {
+	unsigned int size = sizeMB * 1024*1024;
+	unsigned int subsize = (size / sizeof(vector_type));
+
+	vector_type *a = malloc(size);
+
+	printf("size %lld, subsize %lld", size, subsize);
+	vector_type __attribute__ ((aligned(32))) v[256] = {0};
+	while (1){
+		#pragma omp parallel for private(v)
+		for (unsigned int q = 0; q < subsize; q += 256) {
+			for (unsigned int i = 0; i < 256; i++){
+				v[i] += 1;
+			}
+			for (unsigned int i = 0; i < 256; i++) {
+				a[q+i] += v[i];
+			}
+		}
+	}
+	printf("Stress round.\n");
+	free(a);
+}
diff --git a/client/virt/deps/test_cpu_flags/tests.h b/client/virt/deps/test_cpu_flags/tests.h
index b581864..5804793 100644
--- a/client/virt/deps/test_cpu_flags/tests.h
+++ b/client/virt/deps/test_cpu_flags/tests.h
@@ -71,6 +71,7 @@ int ssse3();
 int fma4();
 int xop();
 void stress(inst in);
+void stressmem(unsigned int sizeMB);
 
 
 #endif /* TEST_H_ */
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux