ashwin / coursera-heterogeneous

Resources to work offline on the assignments of Heterogenous Parallel Programming course from Coursera.
70 stars 60 forks source link

Make wbLog do var-args #1

Closed GregBowyer closed 11 years ago

GregBowyer commented 11 years ago

I leave this up to you if you want to merge it, my first attempt was to make the whole thing C99 but that didn't work out all to well (I forgot that the wbLog used in the coursework does not provide a format string, so my version was a seg-fault waiting to happen :S)

If your compiler can do C++0x then this version should do mutliple argument logging

GregBowyer commented 11 years ago

Ok so I got carried away and added timer support for *nix

GregBowyer commented 11 years ago

So as I tried to use wb.h I was beset by devils all not letting me mix c++0x with NVCC. I did get it to link via a tortious route but it would have been portable only to GCC 4.7 and wonderful trickery.

I gave up trying to do it the nice way, the last commit will support extended wbLog, but is super ugly.

I included the skelington of mp1 to show how to compile everything together

ashwin commented 11 years ago

This is excellent! I could not try the variadic template because I do not have access to a C++11 compiler.

I think most people who will use this header file will not have access to a C++11 compiler (VC++ compiler or older gcc for example). So, could you wrap the C++11 code in a suitable #define offering the old non-variadic wbLog in case the compiler does not support variadic template?

GregBowyer commented 11 years ago

It should all now work (as of 86b4b03) with any sane C++ compiler, I could not get nvcc to like C++0x and after much fighting I simply gave up.

wb.h should work fine for anything

ashwin commented 11 years ago

Merged. Sorry for the confusion in the branch. I am a Mercurial user, never used Git or Github before :-)

Your changes are in. I have made a few formatting changes and made compilable with Windows.