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

Diffrence between network vs internet layers, Q. Diffrence between Network ...

Q. Diffrence between Network vs Internet Layers? - Similar to all the other OSI Layers the network layer provides both connectionless and connection-oriented services. From th

Dns records and messages - application layer, DNS Records  and Messages ...

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

What is ping, What is Ping? Ping is a utility program that permits you ...

What is Ping? Ping is a utility program that permits you to check connectivity among network devices on the network. You can ping a device by using its IP address or device nam

What is silly window syndrome, What is silly window syndrome? It is a d...

What is silly window syndrome? It is a difficulty that can ruin TCP performance. This problem happens when data are passed to the sending TCP entity in large blocks, but an int

C-band earth station , Normal 0 false false false EN-US...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Netware protocol provides link-state routing, Which NetWare protocol provid...

Which NetWare protocol provides link-state routing? Ans) NetWare Link Services Protocol (NLSP) gives link-state routing. SAP (Service Advertisement Protocol) advertises network

Routing algorithms, compare routing algorithms with non adaptive algorithms...

compare routing algorithms with non adaptive algorithms

Explain typical network topologies, Question: a) Explain briefly three ...

Question: a) Explain briefly three typical network topologies giving one advantage and one disadvantage of each topology. Explain the three topologies with appropriate diagrams

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