#define START_TIMER(x)\ _asm cpuid\ _asm rdtsc\ _asm mov x, eax#define STOP_TIMER(x)\ _asm rdtsc\ _asm sub eax, x\ _asm mov x, eax#include <cstdlib>#include <cstdio>typedef unsigned timer_t;float DivTest(const float* p, size_t nSize, float* pDiv){ float f = 0.f; for(size_t n = 0; n != nSize; n += 4) { f += p[n] / pDiv[n]; f += p[n + 1] / pDiv[n + 1]; f += p[n + 2] / pDiv[n + 2]; f += p[n + 3] / pDiv[n + 3]; } return f;}float MulTest(const float* p, size_t nSize, float* pMul){ float f = 0.f; for(size_t n = 0; n != nSize; n += 4) { f += p[n] * pMul[n]; f += p[n + 1] * pMul[n + 1]; f += p[n + 2] * pMul[n + 2]; f += p[n + 3] * pMul[n + 3]; } return f;}int main(void){ const int size = 2048; float fValues[size]; float fMuls[size]; float fDivs[size]; for(int i = 0; i != size; ++i) { fValues = float(rand()); fDivs = float(1 + rand() % 4); fMuls = 1.f / fDivs; } timer_t tDiv; START_TIMER( tDiv); float fDiv = DivTest( fValues, size, fDivs); STOP_TIMER( tDiv); timer_t tMul; START_TIMER( tMul); float fMul = MulTest( fValues, size, fMuls); STOP_TIMER( tMul); if( fDiv == fMul) printf("div:%d cycles\nmul:%d cycles\n", tDiv / size, tMul / size); else fprintf( stderr, "error"); system("pause");}
Quote:Original post by Promit
<S>This tag still doesn't work...</S>
Try < strike > instead. ;)
Test:
// This is a blackcomment.
Quote:Original post by PromitWe're trying to wear your fingers down by making you type extra letters. It's a cunning, dastardly plot.
I know strike works.
I want S to work!
are you breaking the forums? or why is the formating broken? could also be the banner on the topright, but i dont think after refreshing 3 times that 3different banners are broken
edit: phew now its ok, you know that this site looks like sh*t without the coloring?
edit2: strange, the last post before my reply is a half day old, or more, but it was listed in active topics under the first 10 or so...
T2k
edit: phew now its ok, you know that this site looks like sh*t without the coloring?
edit2: strange, the last post before my reply is a half day old, or more, but it was listed in active topics under the first 10 or so...
T2k
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement