473,657 Members | 2,571 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 1109
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(in t* 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_cas t<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
1797
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 loop-parallelization or the like since I prefer to prepare the work packets "by hand". I simply need - to specify a list of clients - a means of sending a work packet to a free client and receiving the result (hopefully automatically without need to...
8
4005
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 answer. The problem is this: when the user presses the Calculate button, the whole page is reloaded and, on a large page, this is very noticeable. Is there any way that I can get the calculation done and the result displayed without reloading...
0
2480
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 to use a parent window that allows the user to launch the calculation in a seperate window, so that they could still click "stop" to write a value to a database or set a session level variable that the calculation would check to see if it should...
2
3906
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 calculated fields are not being populated. The database is a samll invoicing database on the form and report we have columns call Unit Cost. This is the actual cost of the part and is pulled from our parts master table and is displayed in a sub form...
1
2261
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 between .. I have checked many of the properties to see what got set unintentionally that might make only the first and last record show the values. Has anyone experienced this? I'm baffled.
4
3268
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 program is doing I show a window which contains a progress bar and a label. At some point during the execution the state of the calculation is changed, so I want to let the user know this. I have placed the creation of the form in a seperate thread...
4
3757
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 calculation is very simple. The calculation is done in an underling query if I can call it a query or I should call it a SQL statement. It looks like a query but it is not saved as the query. The calculation in that query is very simple - ExtendedPrice:*....
5
6243
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 user modifies any of the x, y and z values.
3
3550
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 know nothing about advanced math, so I wrote a C program to help me: (BTW, I guess the result would be ln2.) #include <stdio.h>
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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 we have to send another system
2
1950
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.