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

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

Define routing, Define Routing? The process of determining systematical...

Define Routing? The process of determining systematically hoe to forward messages toward the destination nodes based on its address is known as routing.

What is beaconing, What is Beaconing? The process that permits a networ...

What is Beaconing? The process that permits a network to self-repair networks problems. The stations on the network notify the other stations on the ring when they are not rece

Define the term pipelined processor, Pipelined Processor A pipeline pro...

Pipelined Processor A pipeline processor can be described as a processor which comprises of a series of processing circuits known as segments and a stream of operands (data) is

Error correction - retransmission, When an error is discovered the receiver...

When an error is discovered the receiver is able to ask the sender to retransmit the entire data unit Error Correction-Forward Error Correction A receiver is able to u

Explain about data link layer sub layers, Data Link Layer Sub layers ·  L...

Data Link Layer Sub layers ·  Logical Link Control (LLC) - upper layer · Handles control information, logical addressing and data · MAC (Medium Access Control) - lower layer ·

Explain the basic of network properties, Explain the basic of Network Prope...

Explain the basic of Network Properties   The subsequent properties are related with interconnection networks. 1)  Topology: It refers how the nodes a network are systema

Describe the method of one way redistribution and mutual, Define  the conce...

Define  the concept of one way redistribution and mutual

How intranet is different from internet, How Intranet is different from Int...

How Intranet is different from Internet? Generally an Intranet is different from an Internet in the following ways: i. Intranet is a network within the organisation whereas

Ack received - trasnport layer, ACK Received If an ACK is received by ...

ACK Received If an ACK is received by the  sender. The  SR sender marks  that packet  as having  been received by the receiver.

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