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
SONET Frame Format SONET  uses  a basic  transmission  rate of STS -1 that  is equivalent to 51.84 mbps. Higher level  signals  are integer multiples of the base rate. For  exa

What are the advantages and disadvantages of the three types of routing tables? The three types of routing tables are fixed, dynamic, and fixed central. The fixed table must be

Gigabit Ethernet Data rate of 1000 Mbps or else 1 Gbps Typically implemented as full-duplex with no CSMA/CD 1000Base-X utilizes long-wave optical fiber (1000Base-

What is Medium Access Control of Ethernet? The set of rules which make sure that each node in an Ethernet gets a fair amount of frame transmission opportunity, are known as the

What is the function of the transport system and workbench organizer? The function of the transport system and the Workbench Organizer is to handle any changes made to objects

What is net stat? Netstat is a command line utility program. It gives useful information about the current TCP/IP settings of a connection.

Recognize the command to disable CDP on an interface Ans) Router(config-if)# no cdp enable

Q. What is Sliding Window protocols? Alternatives: Sliding Window protocols - One task begins prior to the other one ends                                     (concept of

Efficiency :- The other main metric used for performance measurement is efficiency of parallel computer system i.e. how the resources of the parallel systems are being utilized