Program for two library methods with thread , Computer Networking

#include

void subdomain(float x[ ], int istart, int ipoints)

{

int i;

for (i = 0; i < ipoints; i++)

x[istart+i] = 123.456;

}

void sub(float x[ 10000], int npoints)

{

int t_num, num_t, ipoints, istart;

#pragma omp parallel default(shared) private(t_num , num_t, ipoints, istart)

{

t_num = omp_get_thread_num(); //thread number of current thread num_t = omp_get_num_threads(); //number of threads

ipoints = npoints / num_t; /* size of partition */

istart = t_num * ipoints; /* starting array index */

if (t_num == num_t-1) /* last thread may do more */

ipoints = npoints - istart;

subdomain(x, istart, ipoints);

}

}

int main()

{

float array[10000];

sub(array, 10000);

 return 0;

}

In this example we used two library methods : omp_get_num_threads() and

omp_get_thread_num().

omp_get_num_threads() returns number of threads that are currently being used in parallel directive.

omp_get_thread_num() returns thread number (an integer from 0 to omp_get_num_threads() - 1 where thread 0 is the master thread).

Posted Date: 3/4/2013 5:22:18 AM | Location : United States







Related Discussions:- Program for two library methods with thread , Assignment Help, Ask Question on Program for two library methods with thread , Get Answer, Expert's Help, Program for two library methods with thread Discussions

Write discussion on Program for two library methods with thread
Your posts are moderated
Related Questions
Some multiple WAN methods are defined below: ARPANET: It start in 1960's. It was operated by Advanced Research Project Agency, which is a company of US defense department.

Packing and Unpacking Data pvm_packs - Pack the active message buffer with arrays of prescribed data type: int info = pvm_packf( const char *fmt, ... ) int info = pv

What is a computer network? Computer Network is a collection of distributed intelligent devices that are connected with each other with transmission media for the purpose of da

What is anonymous FTP and why would you use it Anonymous FTP enables users to join to a host without using a valid login and password. Generally, anonymous FTP uses a login kno

Explain Difference between broadcast domain and collision domain? Ans) Broadcast Domain Send the packet to all the Present Network IT might be send by the person It mig

Has a central core conductor covered in an insulating sheath encased in an outer conductor of metal foil  RG numbers indicate physical specs such as thickness and type of insula

MPMM is a Project Management Methodology which gives a complete "framework" for managing projects. This framework gives you with a step-by-step walkthrough of the phases, activitie

What are the popular topologies other than basic Topologies? Apart from basic topologies some other topologies worth considering are: mesh topology (each device linked to all o

10Base2 an Ethernet term meaning a maximum transmitting rate of 10 Megabits per second that uses baseband signaling, with a contiguous cable segment length of 200 meters (185mts).

Which of the following protocols are used for logical network addressing? Ans) Internet Protocol - IP gives routing and a one interface to the upper layers. No upper layer proto