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

Advantages of bridges - network layer and routing, Advantages of Bridges ...

Advantages of Bridges By forwarding  frames  only to  the segment  where  host  resides  a bridge server the  following  purpose. a.Unwanted  traffic  as well  as network  c

What layer can optionally support reliability, Ans) The Transport Layer : ...

Ans) The Transport Layer : Segments upper-layer applications. Establishes an end-to-end connection. Sends segments from one end host to another. Optionally, make sures

Bit stuffing, bit stuffing program in python

bit stuffing program in python

Network access technologies, Question 1 Explain the following with respect...

Question 1 Explain the following with respect to Data Encoding                     Digital Signaling of Digital Data                     Digital Signal Encoding Techniques Questi

Firewall, confiriguration,capabilities,implementation

confiriguration,capabilities,implementation

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

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

Example of the datalink layer, MAC (media access control) and LLC (logical ...

MAC (media access control) and LLC (logical link control) are both layer 2 protocols.

What is the administrative distance for igrp, IGRP is a distance vector rou...

IGRP is a distance vector routing protocol designed by Cisco. The maximum hop count is 255, and it uses a combination of variables to verify a composite metric. IGRP has an adminis

For making assignment, can you make the assignment plagiarism free and when...

can you make the assignment plagiarism free and when you give me back the assignment. Thanks

Require class and how many different types of class exists, Why do we requi...

Why do we require class and how many different parts of class exists?

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