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

Determine the task which should intranet require Intranet to work smoothly, the following tasks should be properly synchronised: All computers connected together in a n

State the statements about PPP and SLIP for WAN communications?  Ans)    a) PPP uses its Network Control Programs (NCPs) component to encapsulate many protocols.  b) SLIP

Disadvantages of OSPF protocol i) Single Area ii) High Hardware Requirements iii) Troubleshooting

What is WAN? A wide area network is defines a LAN of LANs. WANs connect LANs that might be on opposite sides of a building, across the country or around the world.  WANS

What are reasons behind using layered protocols  Reasons for using layered protocols, using them leads to breaking up design problem into smaller more manageable pieces and lay

Q. TCP-IP and OSI Differences - TCP/IP combines the Presentation and Application Layers - TCP/IP combines the OSI Data Link and Physical Layers into 1 Layer - TCP/IP app

Repeater Repeater is  also named as active hub operates at physical  layer of OSI model. Repeater is an  electronic  device that simply regenerates the signal. Signals travell


What is Ping? Ping is a utility program that permits you to check connectivity among network devices on the network. You can ping a device by using its IP address or device nam