Откуда-то взялось в tracker'еr
Перед запуском не забываем выполнить
ulimit -s 65536
%--- This software is Public Domain, author: pacify
%--- solid-linux.org.ru.c
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#define M 500
#define N 500
#define FXX double
#define DEFM1(A) FXX A[M*N]
#define ADDR1(A,i,j) A[i*N+j]
#define KILL1(A,B,C)
#define INIT1(A,B,C) \
for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) ADDR1(C,i,j) = 0; \
for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) ADDR1(A,i,j) = ADDR1(B,i,j) = (i*j)/(FXX)(M*N);
#define CALC1 for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) { TMP1=0; for (k=N-1;k>0;k--) TMP1 += ADDR1(A1,i,k) * ADDR1(B1,k,j); ADDR1(C1,i,j) = TMP1;}
#define SUMM1 SUM1=0; for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) SUM1+=ADDR1(C1,i,j);
#define DEFM2(A) FXX A[M][N]
#define ADDR2(A,i,j) A[i][j]
#define KILL2(A,B,C)
#define INIT2(A,B,C) \
for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) ADDR2(C,i,j) = 0; \
for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) ADDR2(A,i,j) = ADDR2(B,i,j) = (i*j)/(FXX)(M*N);
#define CALC2 for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) { TMP2=0; for (k=N-1;k>0;k--) TMP2 += ADDR2(A2,i,k) * ADDR2(B2,k,j); ADDR2(C2,i,j) = TMP2;}
#define SUMM2 SUM2=0; for (i=M-1;i>0;i--) for (j=N-1;j>0;j--) SUM2+=ADDR2(C2,i,j);
int main (int argc, char **argv) {
DEFM1(A1); DEFM1(B1); DEFM1(C1);
DEFM2(A2); DEFM2(B2); DEFM2(C2);
unsigned int i;
register unsigned int j,k;
register FXX TMP1,TMP2;
FXX SUM1,SUM2;
clock_t T1,T2,T3,T4;
double delta,d1,d2,d3,d4;
INIT1(A1,B1,C1) T1=clock(); CALC1 T2=clock(); SUMM1
INIT2(A2,B2,C2) T3=clock(); CALC2 T4=clock(); SUMM2
KILL1(A1,B1,C1) KILL2(A2,B2,C2)
delta=((double)((T4-T3)-(T2-T1)))/CLOCKS_PER_SEC;
d1=((double)((T2-T1)))/CLOCKS_PER_SEC;
d2=((double)((T4-T3)))/CLOCKS_PER_SEC;
printf("%7d%7d%7d",M,N,(M*N));
printf("%12.5lf%12.5lf%12.5lf",d1,d2,delta);
printf("%15.7E%15.7E",SUM1/(M*N),SUM2/(M*N));
printf("\n");
return 0;
}
%--- Makefile
NAME = solid-linux.org.ru
OPTS = -O3 -march=native -ffast-math -fomit-frame-pointer -ffast-math
GCC = gcc
result : ${NAME}.c
${GCC} -S ${OPTS} -o ${NAME}.S ${NAME}.c
${GCC} ${OPTS} -o ${NAME} ${NAME}.c
strip --strip-all ${NAME}
Тестирование:
$ make
$ ulimit -s 65536
$ ./solid-linux.org.ru
В результатах вывод программы, CPU type/speed и RAM type/speed, пожалуйста.