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

Define csma/cd, CSMA/CD - A Simple Definition A netwo...

CSMA/CD - A Simple Definition A network station wishing to broadcast will first check the cable plant to make sure that no other station is currently transmit

What advantages does fiber optics have over other media, What advantages do...

What advantages does fiber optics have over other media? One main advantage of fiber optics is that is it less susceptible to electrical interference. It also supports higher ba

What is meant by asymmetrical protocols, There is a many-to-one relationshi...

There is a many-to-one relationship among clients and server. Clients always start the dialog by requesting a service. Servers are passively awaiting for requests from clients.

Determine about the security systems, Determine about the Security Systems ...

Determine about the Security Systems If the company intends to connect to the Internet, then it should pay great attention to the configuration of firewalls. Just as no one wo

Compute shortest path, Compute the shortest path from t to all network node...

Compute the shortest path from t to all network nodes.

Describe any good security technology, Describe any good security technolog...

Describe any good security technology A good security technology should be powerful enough to support the features that the administrators need, including rules validation to i

What are the drawbacks of wireless devices, What are the drawbacks of wirel...

What are the drawbacks of wireless devices One drawback is security. Every random delivery man who happens to be in building can listen on network. Another weakness is reliabil

Different kinds of host in multicasting, What are the different kinds of ho...

What are the different kinds of host in multicasting?

Give the examples of the session layer, Session layer examples  are Netbios...

Session layer examples  are Netbios Names, SQL, NFS, X Windows, and RPC.

Program to load the router with the supplied scripts-ccna, Load the Router ...

Load the Router with the Supplied Scripts Enable ! config term ! hostname Router1 ! enable secret class ! no ip domain-lookup !  interface FastEth

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