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

What are the data units at dissimilar layers of the tcp / ip, What are the ...

What are the data units at dissimilar layers of the TCP / IP protocol suite? The data unit formed at the application layer is called a message, at the transport layer the data

Dns spoofing - domain name server, DNS spoofing This process is genera...

DNS spoofing This process is generally refers to the process of responding a DNS request that was supposed to implement for another server. This can be in the case where the s

Aaa, explain layered protocol architecture

explain layered protocol architecture

Find the bandwidth of the modulated signal, A carrier is frequency modulate...

A carrier is frequency modulated with a sinusoidal signal of 2 kHz, resulting in a maximum frequency deviation of 5 kHz. (a) Find the bandwidth of the modulated signal (b) The ampl

The application layer - fundamentals of networks, The application layer ...

The application layer This  layer enables users  to access the  network  by providing  a few  services to the user some of the protocols and services available to the  user ar

Analysis of parallel algorithms, A generic algorithm is mostly analyzed on ...

A generic algorithm is mostly analyzed on the basis of the following parameters: the time complexity (implementation time) and the space complexity (amount of space necessary). Usu

How can you manage a network using a router, How can you manage a network u...

How can you manage a network using a router? Routers have built in console that lets you configure dissimilar settings, like security and data logging. You can allocate restric

Determine the working of communications intranet, Determine the working of ...

Determine the working of Communications Intranet Intranets of this type tend to feature in geographically dispersed organisations. The motivation for its implementation is g

Labels and label switching, An ATM network is created from interconnected A...

An ATM network is created from interconnected ATM switches. The attachment ports or points can be connected to computers or other ATM switches. As cells reach at an ATM switch, the

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.

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