Menu ▾ ▴

#9 simplethreader example prints result data incorrectly

open
nobody
None
5
2006-08-30
2006-08-30
No

When running the simplethreader example with the
following arguments, the output was incorrect makeing
me believe that something in the example (or the
OptenThreads library) must be wrong:

% Linux64.Opt/SimpleThreader 26 8
...
Data Array:
0 0 0
1 1 1
2 2 2
3 3 3
4 4 5
5 5 6
6 6 7
7 7 -1

I was not really expecting that the OpenThreads library
was buggy in that simple example and the bug is in fact
fust a baaaaadly placed round bracket when printing out
the values:

214c214
< std::cout <<
dataArray[(i*NUM_ELTS/NUM_THREADS)+j] << " ";
---
> std::cout <<
dataArray[(i*(NUM_ELTS/NUM_THREADS)+j] << " ";

It's really a minor bug, but beeing the first example I
looked at I was a little questionning the quality of
the remaining lib ;-)

(of course one could fix the problem as well that not
all NUM_ELTS will be worked on if that number can not
be divided evenly among the NUM_THREADS...)

Discussion

  • Benedikt Kessler

    • summary: simplethreader example prints resut data incorrectly --> simplethreader example prints result data incorrectly
     
  • Benedikt Kessler

    Logged In: YES
    user_id=1586939

    just fixed a spelling error in the subject...

     

Log in to post a comment.