neoragex2015 / nvidia-texture-tools

Automatically exported from code.google.com/p/nvidia-texture-tools
Other
0 stars 0 forks source link

VS2010 compilation errors #161

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When trying to compile the code using VS2010, the TaskDispatcher.h activates 
the HAVE_PPL section, which has several compilation errors. The following patch 
fixes this:

Index: src/nvtt/TaskDispatcher.h
===================================================================
--- src/nvtt/TaskDispatcher.h   (revision 1251)
+++ src/nvtt/TaskDispatcher.h   (working copy)
@@ -92,13 +92,16 @@
         CountingIterator & operator++() { i++; return *this; }
         CountingIterator & operator--() { i--; return *this; }

+               bool operator==(const CountingIterator& o) const { return i == 
o.i; }
+               bool operator!=(const CountingIterator& o) const { return i != 
o.i; }
+
     private:
         int i;
     };

     struct TaskFunctor {
         TaskFunctor(Task * task, void * context) : task(task), context(context) {}
-        void operator()(int & n) const {
+        void operator()(int n) const {
             task(context, n);
         }
         Task * task;

Original issue reported on code.google.com by arseny.k...@gmail.com on 6 Apr 2011 at 3:23

GoogleCodeExporter commented 9 years ago
Thanks! I had never tested that code since I did not have PPL available. Did 
you have to do that for it to work with "parallel_for_each"? or was it 
necessary even with std::for_each?

Original comment by cast...@gmail.com on 6 Apr 2011 at 6:41

GoogleCodeExporter commented 9 years ago
It was necessary with std::for_each; I have not tested the parallel version 
(i.e. the parallel_for_each line is still commented).

Original comment by arseny.k...@gmail.com on 6 Apr 2011 at 2:49

GoogleCodeExporter commented 9 years ago
Oh well, your changes seem to compile as well on VS2009, so I'll leave this as 
is and test it more throughly when I upgrade. Thanks for the bug report!

Original comment by cast...@gmail.com on 6 Apr 2011 at 6:32

GoogleCodeExporter commented 9 years ago
Sorry, I should've checked it more extensively; the trunk now compiles fine in 
Release, however in Debug there is some additional checking code in STL that 
still results in compilation failure; one additional thing in order for 
everything to work is to inherit CountingIterator from std::iterator:

class CountingIterator: public std::iterator<std::bidirectional_iterator_tag, 
int>

After this both Debug & Release compile fine with the most recent trunk code.

Original comment by arseny.k...@gmail.com on 23 Apr 2011 at 12:22

GoogleCodeExporter commented 9 years ago
Also, uh, I would do it this way:

    // Task dispatcher using Microsoft's concurrency runtime.
    struct MicrosoftTaskDispatcher : public TaskDispatcher
    {
        virtual void dispatch(Task * task, void * context, int count)
        {
            TaskFunctor func(task, context);

            Concurrency::parallel_for(0, count, func);
            // for (int i = 0; i < count; ++i) func(i);
        }
    };

No need for CountingIterator at all; the parallel_for version works (as long as 
I uncomment ppl.h include) and has the same performance as that of OpenMP one 
(OpenMP version is selected by default).

Original comment by arseny.k...@gmail.com on 23 Apr 2011 at 12:35

GoogleCodeExporter commented 9 years ago
Cool, thanks for testing that!

Original comment by cast...@gmail.com on 30 Apr 2011 at 11:12