Program for two library methods with thread , Computer Networking

Assignment Help:

#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).


Related Discussions:- Program for two library methods with thread

Cost saving - application layer, Cost Saving Better performance  scala...

Cost Saving Better performance  scalability  and viability  translates into  saving  for  website  operators.  Because  fewer  application  web servers are required  to meet

Name some common or popular databases, Name some common or popular database...

Name some common or popular databases Many of the popular databases also provide support of and to the middleware and consequently, the term middleware has become lesser known.

Timing in mpi program, MPI_Wtime ( ) returns elapsed wall-clock time in sec...

MPI_Wtime ( ) returns elapsed wall-clock time in seconds as some arbitrary point in past. Elapsed time for program segment is specified by the difference between MPI_Wtime values a

Internet infrastructure, Thus now you know how packets travel from one comp...

Thus now you know how packets travel from one computer to another computer over the Internet. however what's in-between? What in fact makes up the Internet infrastructure or backbo

How many types of twisted pair cable are there, How many types of twisted p...

How many types of twisted pair cable are there We can find two types of twisted pair cables, namely: Unshielded Twisted Pair Cable (UTP) and Shielded Twisted Pair Cable (STP).

Ip address, how can u identify the ip class of given ip address

how can u identify the ip class of given ip address

State ieee - ethernet, IEEE 802.3-Ethernet Introduction LAN ...

IEEE 802.3-Ethernet Introduction LAN (Local Area Network) - network connecting devices in a limited geographic area usually privately owned and limited to a single o

What does the user datagram protocol (udp) , UDP is connectionless, and doe...

UDP is connectionless, and does not give error checking. But remember, error checking can happen at other layers too.

Circuit switched networks, Question 1 Write about                       Ci...

Question 1 Write about                       Circuit Switched Networks                       Packet Switched Networks Question 2 Write about                       Protocol Indep

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd