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

Local loop portion of the service starts, What is the juncture at which the...

What is the juncture at which the CPE ends and the local loop portion of the service starts?  Ans) The demarcation or demarc is the juncture at which the CPE ends and the local

Implement a transport layer protocol to transmit data, In this project, you...

In this project, you will implement a Transport Layer protocol to transmit data with Reliable Data Transfer from a client to a server in the presence of channel errors and loss. Th

What is the difference between trigger and rule, What is the difference bet...

What is the difference between trigger and rule? The triggers are known as implicitly by database generated events, whereas stored procedures are known as explicitly by client

Protocols and standards - cable network architecture, Q. Protocols and Stan...

Q. Protocols and Standards - Cable Network Architecture? - Essential in creating as well as maintaining an open and competitive market for equipment manufacturers and in guaran

Difficulties in internetwork communication, Q. Difficulties in Internetwork...

Q. Difficulties in Internetwork Communication? - Data arrive at interface f1 of s1 - How does s1 know that they must be sent out from interface f3? - There is no provisio

What is multicast routing, What is multicast routing? Sending a message...

What is multicast routing? Sending a message to a group is known as multicasting, and its routing algorithm is known as multicast routing.

Explain fat tree interconnection network, Fat tree: It is a customized ver...

Fat tree: It is a customized version of tree network. In this network bandwidth of edge (or connecting wire between nodes) increases in the direction of root. It's a more realisti

Set up to use pvm run and complie, PVM uses two environment variables when ...

PVM uses two environment variables when starting and running. Every PVM user needs to set these two variables to use PVM. The initial variable is PVM_ROOT, which is set to the loca

How to Assign switch ports to VLAN, Assign switch ports to VLANs. Refe...

Assign switch ports to VLANs. Refer to the port assignment table at the starting of the lab to assign ports to the VLANs. Use the interface range command to make simpler this

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