Ответ: Celeron566 :D
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено trainer 12 декабря 2004 г. 14:55
В ответ на: так, проблема тут была, происходило переполнение, похоже, что Intel очень медленно переполнения понимает. Перделал (+) отправлено DASM 11 декабря 2004 г. 23:33

Intel Celeron566, Intel C++ 6, оптимизация под Pentium Pro :D
Исходник:

#include "stdio.h"
#include "windows.h"
int main(int argc, char** argv){
double f = 0;
double k = 1.23456;
double l = 5.6789;
DWORD time = GetTickCount();
for( int i = 0 ; i < 10000 ; i++) {
for( int j = 0 ; j < 10000 ; j++)
f += k * 0.0001*j - 0.0002*i + j / 1234.678;
}
time = GetTickCount()-time;
printf("Result is %f\nCalculation time is %d ms\n", f, time);
return 0;
}
Компилятор сотворил с ним следующее:
;;;    double f = 0;

0000c dd 05 18 00 00
00 fld QWORD PTR _2il0floatpacket.1 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:5.11
00012 dd 5c 24 20 fstp QWORD PTR [esp+32] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:5.11

;;; double k = 1.23456;
;;; double l = 5.6789;
;;; DWORD time = GetTickCount();

00016 ff 15 fc ff ff
ff call DWORD PTR __imp__GetTickCount@0 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:8.17
; LOE eax esi edi
.B1.11: ; Preds .B1.1
0001c 8b e8 mov ebp, eax ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:8.17
; LOE ebp esi edi
.B1.2: ; Preds .B1.11

;;; for( int i = 0 ; i < 10000 ; i++) {

0001e 33 c0 xor eax, eax ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:9.11

;;; for( int j = 0 ; j < 10000 ; j++)
;;; f += k * 0.0001*j - 0.0002*i + j / 1234.678;

00020 dd 05 10 00 00
00 fld QWORD PTR _2il0floatpacket.3 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
00026 dd 05 08 00 00
00 fld QWORD PTR _2il0floatpacket.5 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.10
0002c dd 05 00 00 00
00 fld QWORD PTR _2il0floatpacket.7 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00032 89 6c 24 28 mov DWORD PTR [esp+40], ebp ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00036 dd 44 24 20 fld QWORD PTR [esp+32] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
; LOE eax f1 f2 f3 f5
.B1.3: ; Preds .B1.5 .B1.2
0003a 33 ff xor edi, edi ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.16
0003c be 01 00 00 00 mov esi, 1 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
00041 bd 02 00 00 00 mov ebp, 2 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
00046 89 44 24 18 mov DWORD PTR [esp+24], eax ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
0004a b9 03 00 00 00 mov ecx, 3 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
0004f ba 04 00 00 00 mov edx, 4 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
00054 db 44 24 18 fild DWORD PTR [esp+24] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
00058 d8 cc fmul st, st(4) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
; LOE eax edx ecx ebp esi edi f1 f2 f3 f4 f5
.B1.4: ; Preds .B1.4 .B1.3
0005a eb 06 jmp .L1 ; Prob 0% ;
0005c 8d 74 26 00 ALIGN 4
.L2: ;
00060 de c2 faddp st(2), st ;
.L1: ;
00062 89 7c 24 18 mov DWORD PTR [esp+24], edi ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
00066 dc c1 fadd st(1), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.10
00068 83 c7 05 add edi, 5 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.36
0006b db 44 24 18 fild DWORD PTR [esp+24] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
0006f d9 c0 fld st(0) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
00071 d8 cd fmul st, st(5) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
00073 de c3 faddp st(3), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
00075 d8 cb fmul st, st(3) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00077 de c2 faddp st(2), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00079 89 74 24 18 mov DWORD PTR [esp+24], esi ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
0007d dc c1 fadd st(1), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.10
0007f 83 c6 05 add esi, 5 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.36
00082 db 44 24 18 fild DWORD PTR [esp+24] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00086 d9 c0 fld st(0) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
00088 d8 cd fmul st, st(5) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
0008a de c3 faddp st(3), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
0008c d8 cb fmul st, st(3) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
0008e de c2 faddp st(2), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00090 89 6c 24 18 mov DWORD PTR [esp+24], ebp ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
00094 dc c1 fadd st(1), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.10
00096 83 c5 05 add ebp, 5 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.36
00099 db 44 24 18 fild DWORD PTR [esp+24] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
0009d d9 c0 fld st(0) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
0009f d8 cd fmul st, st(5) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
000a1 de c3 faddp st(3), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
000a3 d8 cb fmul st, st(3) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000a5 de c2 faddp st(2), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000a7 89 4c 24 18 mov DWORD PTR [esp+24], ecx ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000ab dc c1 fadd st(1), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.10
000ad 83 c1 05 add ecx, 5 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.36
000b0 db 44 24 18 fild DWORD PTR [esp+24] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000b4 d9 c0 fld st(0) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
000b6 d8 cd fmul st, st(5) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
000b8 de c3 faddp st(3), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
000ba d8 cb fmul st, st(3) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000bc de c2 faddp st(2), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000be 89 54 24 18 mov DWORD PTR [esp+24], edx ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000c2 dc c1 fadd st(1), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.10
000c4 83 c2 05 add edx, 5 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.36
000c7 db 44 24 18 fild DWORD PTR [esp+24] ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000cb d9 c0 fld st(0) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
000cd d8 cd fmul st, st(5) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.26
000cf de c3 faddp st(3), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.37
000d1 d8 cb fmul st, st(3) ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
000d3 81 ff 10 27 00
00 cmp edi, 10000 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.7
000d9 7c 85 jl .L2 ; Prob 99% ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:10.7
000db de c2 faddp st(2), st ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:11.41
; LOE eax edx ecx ebp esi edi f1 f2 f3 f4 f5
.B1.5: ; Preds .B1.4
000dd dd d8 fstp st(0) ;
000df 40 inc eax ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:9.31
000e0 3d 10 27 00 00 cmp eax, 10000 ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:9.2
000e5 0f 8c 4f ff ff
ff jl .B1.3 ; Prob 99% ;C:\programmer\Msvc6\Projects\Test006\Test006.cpp:9.2
; LOE eax f1 f2 f3 f5
.B1.6: ; Preds .B1.5
000eb dd d9 fstp st(1) ;
000ed dd d9 fstp st(1) ;
000ef dd d9 fstp st(1) ;
000f1 dd 5c 24 20 fstp QWORD PTR [esp+32] ;
000f5 8b 6c 24 28 mov ebp, DWORD PTR [esp+40] ;

Компилятор частично раскрутил цикл по j :)
Результат:
Result is 366655216.142323
Calculation time is 1905 ms
:D

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru