I meant that if I seed every engine uniquely, then my approach seems correct (?)
Type: Posts; User: Niels_M
I meant that if I seed every engine uniquely, then my approach seems correct (?)
Ahh, of course. You are correct, don't know why I didn't realize that.
Do you agree with my overall structure of the program? I.e., that each thread gets its own engine in order to avoid...
Hi
I generate a series of random numbers in parallel (using OpenMP), but depending on what number of threads I invoke, I get a different result. From that I conclude that I have made an error...
Thanks for all the answers and interest.
Is it because it is bad practice, or because it simply doesn't work? Personally I can't see why it wouldn't work.
That being said, I present my approach below, which I believe does exactly as you...
This is my suggestion, using OpenMP (the inner dimension 1 is arbitrarily chosen, I will make it larger as you suggest):
const int outer = omp_get_max_threads();
vector<vector<double> >...
First, thanks for all the replies. There are many good points, so I will answer them independently.
You are right, let me tell more about my goal. Here is the most reduced example of my...
I don't understand this. So people like me that are interested in saving their data in between calculations simply wont gain anything from multithreading? Is there really no other container that I...
Hi
I have a loop, which produces somewhere between 1 and 5 million numbers that I need to keep track of. Normally I would store them all in a std::vector, but since my program is multithreaded, I...
OK, I'll have to keep working on this.. thanks to everyone for participating and helping me advance.
Ah, I see what you mean. That seems like a good approach. It is not stated 100% explicitly, but is this an example of how to achieve your suggestion? If yes, then it is not clear to me, where in that...
Thanks, but as far as I have read online, they are not thread safe either? Or have I misunderstood something? It was not entirely clear from the discussion, there are varying opinions.
Thanks. So I guess the ultimate solution would be to make one RNG for each thread? Do you know how one could do that?
Does anyone know if I would be able to manage this, if I switched over to Boost's threading tools?
Thanks for your contribution, I have made those changes. Even with those optimizations, my program will take a horribly long time to finish. I have the opportunity to run it on a machine with 12...
OK, so I tried adding
#pragma omp critical
which compiles and executes as expected -- but the execution time is similar to that of the unparallelized version. Is there really no other way...
I meant is as in
#pragma omp parallel for private(normal_std_one(engine, nd))
#pragma omp parallel for private(normal_std_one())
#pragma omp parallel for private(normal_std_one)
Why would that be necessary? I mean, it is just a random number generator, would that make any difference?
Nonetheless, I tried to do what you suggest, but none of the following three versions...
I noted it when you posted to begin with, but thanks!
OK, so I guess what I need to do is to
1) declare velocityX, velocityY, velocityZ, dsdfistanceX, distanceY, distanceZ as private
Thanks for the suggestions, both of you. OK, so I will simply insert values instead of appending. But I have come across a different problem (but still OpenMP-related), which is when I use an...
Hi
I have a program, where I
push_back some numbers during a for-loop, as in
for(int i=0; i<1000000000; i++)
{
if(i%10 == 0) num_vec.push_back(i);
Good idea. I would say it looks like this, but I may be very wrong:
new_ptr old_ptr new_size Meaning
------------------------------------------
old_ptr NON-NULL non-zero ...
Thanks. So in general the behavior of realloc is
1) The extension is small such that the old block merely increases its size, but doesn't change its location (new_ptr = old_ptr)
2) The extension...
Hi
I have the following MWE:
#include <stdio.h>
#include <stdlib.h>
int main()
Hi
I have the following minimal non-working example:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>