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
Connection Oriented Transport TCP In addition  to providing  reliable communication transmission control protocols  effects errors  control flow  control  and resequencing of

Session layer examples  are Netbios Names, SQL, NFS, X Windows, and RPC.


This assignment will assess parts of objectives 2-6 from the subject outline: 1 Explain the principles of logical design 2 Discuss the strengths and weaknesses of various net

Source Port Number This fields occupies  the first 16 bytes of the UDP header. This  fields typically hold the UDP port number  of the application sending  this datagram. The

Consider figure.  Assume a new flow E is added that takes a path from R1 to R2 to R6. How does the max-min bandwidth allocation change for the 5 flows?

DNS ID hacking The Dns use ID system in order to keep track of each every request and replies. In order to spoof the DNS’s response, the hacker needs to do ID Hacking. In orde

State about the Cell sectoring With cell sectoring, a cell is separated into a number of wedge-shaped sectors, each with its own set of channels, typically 3 or 6 sectors per c

Design a Logical LAN Topology Step: Design an IP addressing scheme. Given the IP address block of 192.168.7.0 /24, design an IP addressing scheme that states the following r

Explain in brief about the Throughput The medium access control protocol should make as well-organized use as possible of the wireless medium to maximize capacity. Number of