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

Ports, It is an additional 16-bit number which uniquely identifies the spec...

It is an additional 16-bit number which uniquely identifies the specific service on any given machine on the Internet. Port numbers are 16 bit wide, so each of the computers on the

Delivering message through lan, Delivering message through LAN: We hav...

Delivering message through LAN: We have to devise method for delivering message through LAN phase to single, specific destination device. Sending device uses a hardware addres

Give some examples of private network addresses, Give some examples of priv...

Give some examples of private network addresses. 10.0.0.0 with a subnet mask of 255.0.0.0 172.16.0.0 with subnet mask of 255.240.0.0 192.168.0.0 with subnet mask of 255.2

Describe any good security technology, Describe any good security technolog...

Describe any good security technology A good security technology should be powerful enough to support the features that the administrators need, including rules validation to i

What is mesh topology, What is mesh topology Mesh topology is a setup w...

What is mesh topology Mesh topology is a setup wherein every device is linked directly to each other device on the network. Consequently, it needs that each device has at least

Subnet mask, Given the address 172.16.2.120 and the subnet mask of 255.255....

Given the address 172.16.2.120 and the subnet mask of 255.255.255.0. How many hosts are available? Ans) 172.16.2 120 is a standard Class B address with a subnet mask that permit

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