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
Case study on SAN Providers and Products available in the market.

Full Duplex - Capability for simultaneous data transmission among a sending station and a receiving station. It needs a workstation be attached to a switch, the NIC must support it

Question: (a) Describe the importance of backups and the use of antivirus software. (b) With the help of an example/ illustration, explain the term encryption and explain

Question 1: (a) How are IPv4 addresses transformed into IPv6 addresses using IPv4 compatible addresses? (b) Name some of the simplifications that were introduced in IPv6.

Instruction Pipelines The stream of instructions in instruction execution cycle may be realized by a pipeline where overlapped executions of various operations are performed. T

Systolic Array This interconnection network is a kind of pipelined array architecture and it is designed for multidimensional flow of data. It is used for executing fixed algor

What is the full form of FDM and TDM It is both. Each of the 100 channels is possess its own frequency band (FDM), and on every channel two logical streams are intermixed by th


What is primary and secondary ring One of the two FDDI rings is known as the primary ring; the other is called the secondary ring. The primary ring is utilized for data tra

What are the concerns of the Physical Layer? Physical layer coordinates the functions needed to transmit a bit stream over a physical medium. a. Physical characteristics of in