Posts

Showing posts from May, 2012

Fastest way to zero out memory - stream past cache with movntdq/_mm_stream_si128

As a rule of thumb, this technique is only beneficial if the buffer is larger than half the largest level cache. #include <time.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> #include <emmintrin.h> #include <intrin.h> typedef unsigned long long ull ; ull tsc ; int clk ; // Stream 64 Bytes to DRAM, bypass caches. _p must be 16-byte aligned. template < typename T > inline void memstream ( T * _p , const __m128i & i ) { char * p = ( char *) _p ; _mm_stream_si128 (( __m128i *)& p [ 0 ], i ); _mm_stream_si128 (( __m128i *)& p [ 16 ], i ); _mm_stream_si128 (( __m128i *)& p [ 32 ], i ); _mm_stream_si128 (( __m128i *)& p [ 48 ], i ); } inline void serialize () { int a [ 4 ]; __cpuid ( a , 0 );} inline void starttimer () { clk = clock (); serialize (); tsc = __rdtsc ();} inline void stoptimer ( char * n ) { serialize (); ull tsc2 = __rdtsc...

No installers

When publishing software, make it installerless and portable (meaning it shouldn't write it's settings to the registry but to a user specifiable folder (a subfolder of itself by default)). Also, when zipping things up don' t put the files directly in the root folder, forcing people to use the "extract to folder..." option instead of "extract here". This stops people from downloading your software to a temporary folder and opening it in a zip viewing program, then dragging and dropping it somewhere else, because the'y first have to create a folder whereever they want to put it. Instead, create a single folder in the zip and put the files there. Download some of my software to see what I mean.

GnuCalc - A good commandline calculator

Download: Get http://gnuwin32.sourceforge.net/downlinks/calc-bin-zip.php and http://gnuwin32.sourceforge.net/downlinks/readline-bin-zip.php (place readline5.dll in GnuCalc bin folder). For integer only, "set /a 2+2" is good enough. Sources: http://gnuwin32.sourceforge.net/packages/calc.htm http://code.google.com/p/iphucwin32/wiki/Running

highgui.h, highgui.dll download

fatal error C1083: Cannot open include file: 'highgui.h': No such file or directory Just came across some OpenGL Tutorials  which depend on OpenCV Lib's Image loading. OpenCV is a huge library with tons of other stuff you won't need for compiling these samples, so I went ahead and repacked just everything you need for compiling and running these samples (only tested simpleGLUT-Texturing). highgui_h_lib_ocv_x86_vs10.zip  (only vs10x86 binaries and required headers included) When compiling these samples, make sure to set Linker > General > Output File back to default and remove any input libraries, then add the ones included here (e.g. by just drag and dropping them into the source file area of vs10) and copy the dlls in bin to your project dir.