Skip to content

Instantly share code, notes, and snippets.

@myun2
Last active August 29, 2015 14:05
Show Gist options
  • Save myun2/9880d58955ac35700d63 to your computer and use it in GitHub Desktop.
Save myun2/9880d58955ac35700d63 to your computer and use it in GitHub Desktop.
intel-avx
#include <stdio.h>
#include <time.h>
#define YOUR_CLOCK_MH (1600)
#define COUNT (64)
int main()
{
unsigned long long i, j;
float s[COUNT];
float r = 0;
for(i=0; i<COUNT; i++)
s[i] = clock();
for(i=0; i<(unsigned long long)1000 * 1000 * YOUR_CLOCK_MH; i++) {
for(j=0; j<COUNT; j++)
s[j] += 3.89;
}
for(i=0; i<COUNT; i++)
r += s[i];
printf("%f\n", r);
printf("Time in: %d\n", clock());
return 0;
}
all:
gcc intel-avx-test.c -O3 -o a.out
gcc intel-avx-test.c -O3 -S
./a.out
nosse:
gcc intel-avx-test.c -O3 -mno-sse -o a.out
gcc intel-avx-test.c -O3 -S -mno-sse
./a.out
std:
gcc intel-avx-test.c -O3 -std=c99 -o a.out
./a.out
avx:
gcc intel-avx-test.c -O3 -mavx -o a.out
gcc intel-avx-test.c -O3 -S -mavx
./a.out
avx2:
gcc intel-avx-test.c -O3 -mavx2 -o a.out
gcc intel-avx-test.c -O3 -S -mavx2
./a.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment