From: <axl...@us...> - 2010-11-13 21:42:31
|
Revision: 765 http://hgengine.svn.sourceforge.net/hgengine/?rev=765&view=rev Author: axlecrusher Date: 2010-11-13 21:42:25 +0000 (Sat, 13 Nov 2010) Log Message: ----------- add benchmark so that we can keep track of tests that we do Added Paths: ----------- Mercury2/src/Benchmark.cpp Mercury2/src/Benchmark.h Added: Mercury2/src/Benchmark.cpp =================================================================== --- Mercury2/src/Benchmark.cpp (rev 0) +++ Mercury2/src/Benchmark.cpp 2010-11-13 21:42:25 UTC (rev 765) @@ -0,0 +1,44 @@ +#include <Benchmark.h> +#include <stdio.h> +#include <stdlib.h> + +void BenchmarkSSELoad() +{ + /*_mm_load_ps and _mm_loadu_ps seem to run at nearly the same speed + _mm_loadu_ps 5.886555ns vs _mm_load_ps 5.564690ns + */ + MercuryTimer start; + const unsigned long c = 1024*1024*20; + FloatRow* d = new FloatRow[c]; + //d = (FloatRow*)(((char*)d)+4); + printf("%d\n", ((unsigned long)d)%16); + __m128 pp; + unsigned long* idx = new unsigned long[c]; + for (int x = 0; x<c;++x) + { + unsigned int r = (unsigned int)rand(); + idx[c] = r%c; + } + + double tu, ta; + tu = ta = 0; + for (int x = 0; x<10;++x) + { + start.Touch(); + for (unsigned int i = 0; i < c;++i) + { + pp=_mm_loadu_ps(d[i]); + _mm_storeu_ps(d[i],pp); + } + tu += start.Touch()*1000000000; //to nano second + for (unsigned int i = 0; i < c;++i) + { + pp=_mm_load_ps(d[i]); + _mm_store_ps(d[i],pp); + } + ta += start.Touch()*1000000000; //to nano second + } + printf("loadu %f\n", tu/float(c)/10/2); + printf("load %f\n", ta/float(c)/10/2); + exit(0); +} \ No newline at end of file Added: Mercury2/src/Benchmark.h =================================================================== --- Mercury2/src/Benchmark.h (rev 0) +++ Mercury2/src/Benchmark.h 2010-11-13 21:42:25 UTC (rev 765) @@ -0,0 +1,41 @@ +#ifndef MBENCHMARK_H +#define MBENCHMARK_H + +#include <MercuryTimer.h> +#include <MercuryMath.h> + +void BenchmarkSSELoad(); + +#endif + +/**************************************************************************** + * Copyright (C) 2010 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |