Program for two library methods with thread , Computer Networking

#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).

Posted Date: 3/4/2013 5:22:18 AM | Location : United States







Related Discussions:- Program for two library methods with thread , Assignment Help, Ask Question on Program for two library methods with thread , Get Answer, Expert's Help, Program for two library methods with thread Discussions

Write discussion on Program for two library methods with thread
Your posts are moderated
Related Questions
TYPES OF WIRES:  Cable used for wiring would match the following: The intended speed The distance between computers The amount of noise Anticipated future r


Internet Backbone Internet backbone  is the  physical  networks ( usually relying  on fiber optic  cable ) that  carries  internet  traffic between  different  networks  and i

Question: Consider that you have to configure a small WLAN of 8 computers using Wired Equivalent Privacy (WEP) and that you have to best make use of its available security f

Define the term - Graphics Interchange Format A type of graphics file found frequently on the .net. A picture of a vice-president, for example, may appear on the Intranet as

Fast Ethernet Operates at 100 Mbps faster speeds required for image processing, CAD, real-time audio and video No change in frame addressing, format or access method

What is IPv6? IPv6, or Internet Protocol version 6, was developed to change IPv4. At present, IPv4 is being used to control internet traffic, butis expected to get saturated in

Groupware addresses the management of semi-structured information like text, image, mail, bulletin boards and the flow of work. These Client/Server systems have people in direct co

What are the disadvantages of Star Topology? The disadvantages are considered as follows: a. Needs more cable than most topologies. b. Moderately complex to install.

What are TP-Lite and TP-Heavy Monitors? TP-Lite is simply the integration of TP Monitor functions in the database engines. TP-Heavy is TP Monitors which handles the Client/S