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

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

Define retransmission, Define Retransmission? Retransmission is a proce...

Define Retransmission? Retransmission is a process in which the receiver detects the occurrence of an error and asks the sender to resend the message. Resending is repeated unt

Protocol gets a hardware address from a known ip address, Normal 0 ...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Categories of networks, Distance covered, Based on size, ownership and phys...

Distance covered, Based on size, ownership and physical architecture - LAN (Local Area Network) - Suitable for smaller geographical area - MAN (Metropolitan Area Network) - S

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 load balancing, If the number of incoming clients invokes exceeds t...

If the number of incoming clients invokes exceeds the number of processes in a server class, the TP Monitor might be dynamically start new ones and this is known as Load balancing.

What is connection-oriented communication, What is Connection-oriented comm...

What is Connection-oriented communication Connection-oriented communication can be in three phases. In establishment phase a request is made to set up the connection. Only afte

Distribution system from bss, To Distribution System from BSS We requir...

To Distribution System from BSS We require to identify the AP as the first hop to the destination (B) A will receive an ACK from the AP - indicates frame successfully on

Public key cryptography and private key cryptography, Question: a) Di...

Question: a) Differentiate between the following key terms used in any e-banking security system: (i) Authorisation v/s Authentication. (ii) Data Integrity v/s Data Conf

Function of tcp - ip transport layer, Q. Function of TCP/IP Transport Layer...

Q. Function of TCP/IP Transport Layer ? TCP/IP Transport Layer - Defines two standard transport protocols UDP and TCP - TCP equipment a dependable data-stream protocol

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