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

Show the need for network layer, Q. Show the Need for Network Layer? N...

Q. Show the Need for Network Layer? Need for Network Layer - To solve the problem of delivery of data through several links. - Accountable for Host to Host delivery

What is ping utility, PING - Packet Internet Gopher A utility that shows...

PING - Packet Internet Gopher A utility that shows connections to one or more remote hosts. The ping command uses the ICMP echo request and echo reply packets to verify whether

Mime the multipurpose internet mail extensions, MIME The Multipurpose Inter...

MIME The Multipurpose Internet Mail Extensions While  the message  headers described in are satisfactory for sending  ordinary  ASCII text they are  not sufficiently Reich for

Illustrate 802.11b HR DSSS, 802.11b HR DSSS a) High-rate DSSS using a ...

802.11b HR DSSS a) High-rate DSSS using a 2.4 GHz band b) Similar to DSSS excluding for encoding method c) Uses complementary code keying (CCK), encoding 4 or 8 bits to

Domains and sub domains, Hosts are generally, individual machines at a spec...

Hosts are generally, individual machines at a specific location. Normally Resources of host machine are shared and can be used by any user on Internet. Hosts & local networks are g

What is wan, What is WAN? A wide area network is defines a LAN o...

What is WAN? A wide area network is defines a LAN of LANs. WANs connect LANs that might be on opposite sides of a building, across the country or around the world.  WANS

Name three agent development toolkits, QUESTION (a) Name two properties...

QUESTION (a) Name two properties of an agent (b) List the three characteristics used to classify agents according to the Nwana Taxonomy (c) Agent environments can be clas

Which layer is responsible for coordinating communication , Which layer is ...

Which layer is responsible for coordinating communication between systems Ans) The Session layer performs the following: Responsible for establishing and maintaining connections

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