Esempio n. 1
0
void stress(inst in) {

	// arrays must be aligned by 16
	float *a = malloc(sizeof(float)*size);
	float *b = malloc(sizeof(float)*size);
	// define two arrays
	for (int i = 0; i < size; i++) {
		b[i] = rand();
	}
	omp_set_num_threads(in.num_threads);
	#pragma omp parallel
	while (1){
		AddTwo(a, b, in.num_threads); // call AddTwo function}
		if (in.avx)
			avx();
		if (in.sse4)
			sse4();
		if (in.sse3)
			sse3();
		if (in.ssse3)
			ssse3();
		if (in.aes)
			aes();
		if (in.pclmul)
			pclmul();
		if (in.rdrand)
			rdrand();
		if (in.fma4)
			fma4();
		if (in.xop)
			xop();
		if (in.sse4a)
			sse4a();
		printf("Stress round.\n");
	}
	free(a);
	free(b);
}
Esempio n. 2
0
int main(int argc, char **argv) {
	int c;
	int digit_optind = 0;
	int opt_count = 0;

	int ret = 0;
	while (1) {
		int this_option_optind = optind ? optind : 1;
		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 },
				{ "sse4a",  no_argument, 0, 0 },
				{ "avx",    no_argument, 0, 0 },
				{ "aes",    no_argument, 0, 0 },
				{ "pclmul", no_argument, 0, 0 },
				{ "rdrand", no_argument, 0, 0 },
				{ "fma4",   no_argument, 0, 0 },
				{ "xop",    no_argument, 0, 0 },
				{ 0, 0, 0, 0}};

		c = getopt_long(argc, argv, "", long_options, &option_index);
		if (c == -1){
			if (!opt_count)
				print_help();
			break;
		}

		switch (c) {
		case 0:
			switch (option_index) {
			case 0:
				stress(parse_Inst(optarg));
				break;
			case 1:
				stressmem(atoi(optarg));
				break;
			case 2:
				ret += sse3();
				break;
			case 3:
				ret += ssse3();
				break;
			case 4:
				ret += sse4();
				break;
			case 5:
				ret += sse4a();
				break;
			case 6:
				ret += avx();
				break;
			case 7:
				ret += aes();
				break;
			case 8:
				ret += pclmul();
				break;
			case 9:
				ret += rdrand();
				break;
			case 10:
				ret += fma4();
				break;
			case 11:
				ret += xop();
				break;

			}
			break;

		case '?':
			print_help();
			break;

		default:
			printf("?? getopt returned character code 0%o ??\n", c);
			break;
		}
		opt_count += 1;
	}
	if (ret > 0) {
		printf("%d test fail.\n", ret);
		exit(-1);
	}
	exit(0);
}