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

Explain the types of security threats, Q. Explain the types of Security Thr...

Q. Explain the types of Security Threats? (a) Normal Flow (b) Interruption: An asset of a system develops into unavailable or unusable. (c) Interception: A few unaut

Illustrate the term- search engine and surfing, Illustrate the term- Search...

Illustrate the term- Search Engine and Surfing Search Engine: Software used to find information on the Web. Examples are Google, Lycos and Yahoo. Server: A computer with

Network topologies- -fundamentals of networks, Network Topologies Topo...

Network Topologies Topology is study  of the  arrangement or  mapping of  the elements links nodes etc,  of a network especially the physical and logical inter connections bet

Explain about the database management intranet, Explain about the Database ...

Explain about the Database Management Intranet This type of Intranet provides everyone in an organisation with the capability to maintain a "real-time" interactive database.

What are the drawbacks of ethernet cabling, What are the drawbacks of Ether...

What are the drawbacks of Ethernet Cabling? The Ethernet cabling ahs the following drawbacks: 1. Ethernet is not a high-level performer in high-load environments. This proto

Fiber optic extension, FIBER OPTIC EXTENSION:  The LAN extension using f...

FIBER OPTIC EXTENSION:  The LAN extension using fiber optic is given in the figure below:   Figure The fiber-modem translates digital data into pulses of light the

Recognize the command that shows the sap table, show ipx servers is the co...

show ipx servers is the command that shows the SAP table

Name the two types of oltp, a) TP lite , based on stored procedures. b)...

a) TP lite , based on stored procedures. b) TP heavy , based on the TP monitors.

Program, i need the job to be done within 3days

i need the job to be done within 3days

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