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

What is Daemon A daemon is a UNIX background process that implements the server side of a protocol. Daemons are unique to UNIX. For example, FTP stands for the File Transfer

What is tracert? Tracert is a Windows utility program that can used to trace the route taken by data from the router to the destination network. It also represents the number o

Can you describe encapsulating, carrier and passenger protocol?

Security models by giving striking analogies to the real world A classical case study: (With due acknowledgements to the security exponent who proposed this theory.) He has c

VLAN - Virtual Local Area Network Vlan is a logical grouping or segmenting a network linked to administratively described ports on a switch, they give Broadcast control, Securit

Wait protocol The wait protocol is used for resolving the conflicts, which arise due to number of multiprocessors demanding the same resource. There are two types of wait prot

What are the main categories based on which applications of computer network can be categorized? The major areas under which the applications for computer network can be divide

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

DNS Records  and Messages Two types  of records  are used DNS. The  question records  are used in the question  section of the query and response  messages. The resource  reco