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

Firewalls - point to point, Firewalls After several  security  related ...

Firewalls After several  security  related internet  newsgroups  started overflowing  with posts it becomes  clear something  hand to done to help  secure  networks. The first

Explain control frame of claim token, Control Frame: claim_token Co...

Control Frame: claim_token Consider first station turned on Station notices no tokens Sends claim_token No competitors, so makes a ring of just itself P

ppp error detection on cisco routers , Which form of PPP error detection o...

Which form of PPP error detection on Cisco routers monitors data dropped on a link?  Ans) The Quality protocol monitors data dropped on a link. Magic Number avoids frame looping

Explain the three principles of data communication system, Question 1 Vide...

Question 1 Videoconferencing is used to conduct meetings with the people who are located in far distance. Videoconferencing is an example of which type of computer networks? Expla

What are the advantages of adaptive routing, What are the Advantages of ada...

What are the Advantages of adaptive routing  (1) An adaptive routing method can improve performance, as realised by the network user. (2) An adaptive routing method can aid

Explain fat tree interconnection network, Fat tree: It is a customized ver...

Fat tree: It is a customized version of tree network. In this network bandwidth of edge (or connecting wire between nodes) increases in the direction of root. It's a more realisti

Html, write a html program segment that contains hypertext links from one d...

write a html program segment that contains hypertext links from one document to anothersk question #Minimum 100 words accepted#

Tp-lite and tp-heavy monitors, What are TP-Lite and TP-Heavy Monitors? A...

What are TP-Lite and TP-Heavy Monitors? Ans) TP-Lite is simply the integration of TP Monitor functions in the database engines.TP-Heavy are TP Monitors which handles the Client/

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