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

Delivering message through lan, Delivering message through LAN: We hav...

Delivering message through LAN: We have to devise method for delivering message through LAN phase to single, specific destination device. Sending device uses a hardware addres

Higher bandwidth - computer network, Higher bandwidth Fibre  optic  ...

Higher bandwidth Fibre  optic  cable an  support  dramatically higher bandwidths than  either   twisted pair or  coaxial  cable currently data rates  and bandwidth utilizatio

Define what is a software agent, QUESTION (a) Define what is a software...

QUESTION (a) Define what is a software agent? (b) An intelligent agent is known to exhibit several characteristics or properties that distinguish it from another piece of so

Fat tree, Fat tree It is a modified version of the tree network. In thi...

Fat tree It is a modified version of the tree network. In this group the bandwidth of edge (or the connecting wire among nodes) increases towards the root. It is a more practic

Hacking, can u send me a hacking software of face book for free

can u send me a hacking software of face book for free

Explain semantic web , What the Semantic Web is? Ans) The Semantic Web ...

What the Semantic Web is? Ans) The Semantic Web is a vision, that thinks to join together dispersed bits of data on the internet, very much like web pages are presently joined

Advantages, What are advantages of having e-commerce over extranets

What are advantages of having e-commerce over extranets

Dotted decimal notation, Dotted decimal representation is a syntactic form ...

Dotted decimal representation is a syntactic form the IP software uses to express 32-bit binary numbers when communicating with humans. Dotted decimal presents every octet in decim

Error detection and correction, Error detection and correction The digi...

Error detection and correction The digital traffic stream of second generation systems also lends itself to the use of error detection and correction methods. The result can be

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