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

Connection-oriented protocol, TCP is connection-oriented. Connection-orient...

TCP is connection-oriented. Connection-oriented is a kind of connection established between the source & destination machines before any data is sent that means a connection is est

Time out - transport layer, Time out The  protocols  name Go Back  N i...

Time out The  protocols  name Go Back  N is  derived  from the  sender behaviour in the  presence  of lost or  overly  delayed packets. A timer will again  be used  to recover

Residential access - computer network, Residential Access Residential ...

Residential Access Residential  access is connecting home  end  systems ( typically a PC but increasingly a home network) into the network. One form  of residential  access  i

Advantages of vpns - point to point , Advantages of VPNs Advantages di...

Advantages of VPNs Advantages discussed in the following  section include those related to security. Consolidation transparency cost. And administration. a. Improved secur

How does a token-passing protocol works, How does a Token-Passing Protocol ...

How does a Token-Passing Protocol works? The token-passing protocol relies on a control signal known as the token. A token is a 24-bit packet that circulates throughout the net

Explain types of redundancy checks, Q. Explain Types of Redundancy Checks? ...

Q. Explain Types of Redundancy Checks? Parity Check Simple Parity Check Two Dimensional Parity Check / Longitudinal Redundancy Check (LRC) CRC (Cyclic Redund

Give example of the physical layer, FDDI, Token Ring and Ethernet are all p...

FDDI, Token Ring and Ethernet are all physical layer framing standards.

Characterization of networks, CHARACTERIZATION OF NETWORKS:  There are...

CHARACTERIZATION OF NETWORKS:  There are three kinds of characterization of networks. LOCAL AREA NETWORK (LAN):  It is needed for a single building. METROPOLOTAN AREA

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