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

How do you disable advanced editing, We can deactivate advanced editing us ...

We can deactivate advanced editing us using  terminal no editing

What is internet, I have a project on Information Communication Technology(...

I have a project on Information Communication Technology(I.C.T). So sir I want to know that what is internet? and how it works?

Show scalability and reliability of computer network, How do you account fo...

How do you account for higher scalability and reliability of computer network? Ans: Computer network will have a large number of computers, which can share database, software

Explain the multipath resistance, Explain the Multipath resistance The ...

Explain the Multipath resistance The chipping codes used for CDMA not only exhibit low cross-correlation but also low autocorrelation. Thus, a version of the signal that is del

What are the advantages of the intranet, What are the Advantages of the int...

What are the Advantages of the intranet The most easily noticeable difference between an Internet server and an Intranet server such as Lotus Notes is their design philosophy.

Synchronous tdm and statistical tdm, Difference between synchronous tdm and...

Difference between synchronous tdm and statistical tdm

Processor arrangements-array, Processor Arrangements It is a very frequ...

Processor Arrangements It is a very frequent event in data parallel programming to group a number of processors to perform definite tasks. To reach this goal, HPF gives a direc

Connectionless protocol at the transport layer, User Datagram Protocol - UD...

User Datagram Protocol - UDP is a connectionless oriented transport protocol for use when the upper layers give error-recovery and reliability. UDP does not sequence data or re-ass

What is data link of osi model, Q. What is data link of osi model? - Th...

Q. What is data link of osi model? - The data link layer offers access to the networking media and physical transmission across the media and this enables the data to locate it

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