473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculation parallelization

Hello,

Please help me with calculation parallelization. I have 2
processors DELL PRECISION 530 computer and I'd like
parallelize cycles like
for(int i = 0; i < last; ++i)
{
a[i] = b[i] + c[i];
}

I've read about '#pragma omp parallel for' instruction for
the future version of VC++(Visual C++ "Whidbey": Advanced
Code Generation ). What can I do with VC++6 and VC++ .NET
2003?

Regards

Leonid

Nov 16 '05 #1
1 1102
Leonid wrote:
Please help me with calculation parallelization. I have 2
processors DELL PRECISION 530 computer and I'd like
parallelize cycles like
for(int i = 0; i < last; ++i)
{
a[i] = b[i] + c[i];
}


Just make two worker threads which would work on one half of your
data. One (and only) parameter of a worker thread should be pointer to
a struct embodying your input and output parameters, like:

class ThreadParams
{
public:
ThreadParams(int* o, int* i1, int* i2, size_t l) : output(o),
input1(i1), input2(i2), length(l) {}

int* output;
int* input1;
int* input2;
size_t length;
}

Worker thread function should look like this:

unsigned int __stdcall ThreadProc(void* pParam)
{
ThreadParams* pParams = reinterpret_cast<ThreadParams*>(pParam);
size_t i;

for (i = 0; i < pParams->length; ++i)
pParams->output[i] = pParams->input1[i] + pParams->input2[i];

return 0;
}

You create non-MFC threads with _beginthreadex and MFC threads with
AfxBeginThread. ThreadParams class should be created on heap like this:

ThreadParams* pTp = new ThreadParams(a+last/2, b+last/2, c+last/2,
last/2);

Also consider the situation where <last> is odd number.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1784
by: Mathias | last post by:
Dear NG, I have a (pretty much) "emberassingly parallel" problem and look for the right toolbox to parallelize it over a cluster of homogenous linux workstations. I don't need automatic...
8
3998
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
2470
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
3892
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
2246
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
4
3256
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
4
3745
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
6222
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
3531
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.