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

Computer networks - fundamentals of networks , Computer Networks A com...

Computer Networks A computer  networks  can be defined as set of computer that  interact  among  the individual  computers sharing  resources or information. Reference models

Osi reference model, - The model was developed by the ISO (International Or...

- The model was developed by the ISO (International Organisation for Standardisation) in 1984. It is currently considered the primary Architectural model for inter-computer communi

Configure basic switch parameters- ccna, Configure basic switch parameters....

Configure basic switch parameters. Configure the S1, S2, and S3 switches according to the following guidelines: Configure the switch hostname. Disable DNS lookup.

What is meant by 3-tier architecture, In 3-tier Client/Server systems, the ...

In 3-tier Client/Server systems, the application logic (or process) lives in the middle tier and it is removed from the data and the user interface. In theory, the 3-tier Client/Se

Physical addressing in a wan, PHYSICAL ADDRESSING IN A WAN:  The physi...

PHYSICAL ADDRESSING IN A WAN:  The physical addressing in a WAN is same as in LAN in the following way: The data is send in packets equivalent to frames. Every pack

Require class and how many different types of class exists, Why do we requi...

Why do we require class and how many different parts of class exists?

Address space, Internet addresses are divided in five distinct types of cla...

Internet addresses are divided in five distinct types of classes. The classes were designated A by E. class A address space lets a small number of networks although a large number

Combinational circuit for sorting the string, Every input line of the combi...

Every input line of the combinational circuit represents an individual element of the string say xi and every output line results in the form of a sorted list. In order to attain t

Features of fdm - fundamentals of networks, Features of FDM 1.The FDM ...

Features of FDM 1.The FDM channel carries  only  one phone  circuit  at a time. 2.If an FDM channel is not in sue then  it is  sits idle and cannot be   used by  other user

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