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

Electrical characteristics of 9-pin RS232 connector, Q. Electrical Characte...

Q. Electrical Characteristics of 9-Pin RS232 Connector? Electrical Characteristics - Single-ended One wire per signal and voltage levels are with respect to s

Networking concepts and applications, iLab 2: Office Network Expansion ...

iLab 2: Office Network Expansion Connect to the iLab here. Submit your assignment to the Dropbox located on the silver tab at the top of this page. (See "Due Da

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

Network and system administration, The goal of this assignment is to provid...

The goal of this assignment is to provide an exposure to Network and System Administration issues. For the project, you are required to design/configure/implement/test/review a Net

Describe about the noiseless channel, Describe about the noiseless channel ...

Describe about the noiseless channel A noiseless channel can transmit an arbitrarily large amount of information, no matter how frequently it is sampled. Just send a lot of dat

Define osi , OSI= Open System Interconnection.

OSI= Open System Interconnection.

What is mesh topology, What is mesh topology Mesh topology is a setup w...

What is mesh topology Mesh topology is a setup wherein every device is linked directly to each other device on the network. Consequently, it needs that each device has at least

State the nonselective fading and selective fading, Nonselective fading and...

Nonselective fading and Selective fading Nonselective fading, is a fading in which all frequency methods of the received signal fluctuate in the similar proportions simultaneo

Why is the authentication and key agreement of 3gpp weak, Question 1: a...

Question 1: a) How is the four-way exchange employed for mutual authentication in WPA/RSN? b) Elaborate on how inquiry attacks and traffic monitoring attacks can be u

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