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

Network, do you do paraphrase

do you do paraphrase

Two items that tcp and udp share in common, Recognize the two items that TC...

Recognize the two items that TCP and UDP share in common? Ans) TCP and UPD are both layer 4 Transport protocols and both use port number to recognize upper level applications.

Request to a server, If a client gives a 4096-byte request to a server loca...

If a client gives a 4096-byte request to a server located 50 km away on a 1 Gbps fiber optic, then what is the efficiency of the line during this time? Suppose that the server give

INAB-426-, As• New Content (Week 5) o System Integration Implementation P...

As• New Content (Week 5) o System Integration Implementation Plan ? Develop a detailed implementation plan that captures the following (address 4 of these): ? Testing activitie

Matlab chi square functioning, Create a custom chi-square function in matla...

Create a custom chi-square function in matlab, MATLAB in Statistics

Acknowledgment number - transport layer, Acknowledgment number This 32...

Acknowledgment number This 32 bit  field  defines  the byte  number that the  from the  segment is expecting to  receive the segment is expecting to receive from the other par

Define router. explain its type, Question 1 Define Router. Explain its typ...

Question 1 Define Router. Explain its type Question 2 List and discuss the different concepts of EIGRP Question 3 Explain the concept of autonomous system Autonomo

Difference among the communication and transmission, Difference among the c...

Difference among the communication and transmission. Transmission is a physical movement of information and concern issues like bit polarity, synchronisation, clock etc. Com

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