Arrays pointers for parallel algorithms, Computer Networking

Assignment Help:

Arrays Pointers

An array is a set of the same type of data. Arrays are very well-liked data structures in parallel programming due to their easiness of use and declaration. At the single hand, arrays can be used as a common memory resource for the shared memory programming; on the other hand they can be simply partitioned into sub-arrays for data parallel programming. This is the easiness of the arrays that creates them most frequently used data structure in parallel programming.  We shall study arrays in the context of two languages C and Fortran 90.

Consider the array shown below. The size of the array is 10.

5

10

15

20

25

30

35

40

45

50

Index of the primary element in Fortran 90 is 1 but that in C is 0 and therefore the index of the last element in Fortran 90 is 10 and that in C is 9. If we assign the name of array as A, then ith element in Fortran 90 is A(i) but in C  it is A[i-1].  Arrays may be one- dimensional or they might be multi-dimensional.

General form of declaration of array in Fortran 90 is

type, DIMENSION(bound) [,attr] :: name

for example the declaration

INTEGER, DIMENSION(5): A

declare an array A of size 5.

General form of declaration of array in C is

type array_name [size]

For example the declaration A

int A[10]

declares an array of size 10.

Fortran 90 allows one to use particular sections of an array. To access a section of an array, you require the name of the array followed by the two integer values divided by a colon enclosed in the parentheses. The integer values signify the indices of the section required.

For example, a(3:5) refers to elements 3, 4, 5 of the array, a(1:5:2) refers to elements 1, 3, 5 of the array , and b(1:3, 2:4) refers to the elements from rows 1 to 3 and columns 2 to 4. In C there is only one type of array whose size is determined statically, though there are provisions for dynamic allocation of storage by pointers and dynamic memory allocation functions like calloc and malloc functions. In Fortran 90, there are 3 possible kinds of arrays depending on the binding of an array to an amount of storage : Static arrays with fixed size at the time of declaration and cannot be altered during implementation ; Semi-dynamic arrays or automatic arrays: the size is determined after entering a subroutine and arrays can be formed to match the exact size needed, but local to a subroutine ; and Dynamic arrays or  allocatable arrays  : the size can be altered during implementation.

In these languages, array operations are written in a compact form that often makes programs more clear.

Consider the loop:

s=0

do i=1,n a(i)=b(i)+c(i)

s=s+a(i)

end do

It can be written (in Fortran 90 notation) as follows:

a(1:n) = b(1:n) +c(1:n)

s=sum(a(1:n))

In addition to Fortran 90, there are lot of languages that gives succinct operations on arrays. Some of the most liked are APL, and MATLAB. While these languages were not developed for parallel computing, quite for expressiveness, they can be used to state parallelism since array operations can be easily implemented in parallel. Therefore, all the arithmetic operations (+, -, * /, **) engaged in a vector expression can be performed in parallel. Intrinsic reduction functions, such as the sum above, also can be done in a parallel .


Related Discussions:- Arrays pointers for parallel algorithms

Illustrate nonboundary-level masking with example, Q. Illustrate Nonboundar...

Q. Illustrate Nonboundary-Level Masking with example? Nonboundary-Level Masking Example IP address 45 123 21 8 Mask 255 192 0 0 Subnet 45 64 0 0 123 0

use dijkstras shortest-path algorithm compute short path, Consider the fol...

Consider the following network example. With the indicated link costs along each link in the figure, use Dijkstra's shortest-path algorithm to compute the shortest path from x to a

Explain data communications, The distance over which data moves within a co...

The distance over which data moves within a computer may differ from a few thousandths of an inch, as is the case within a one IC chip, to as much as lot of feet along the backplan

Estimate of average delay deviation, Consider the procedure described for e...

Consider the procedure described for estimating average delay di. Suppose that u=0.1. Let r1-t1 be the most recent sample delay, let     r2 -t2 be the next most recent sample delay

List the advantages of arcnet, List the advantages of ARCNet. Here are ...

List the advantages of ARCNet. Here are some of the ARCNet's benefits: 1.  It is extremely reliable. 2. ARCNet is simple to install and troubleshoot. 3. It has an exce

Off the shelf company, Draw a work breakdown structure (WBS) diagram for th...

Draw a work breakdown structure (WBS) diagram for the project, to show all the planned tasks. This WBS should contain at least two levels. b) Explain the main differences between

Determine the application areas of intranet, Determine the Application area...

Determine the Application areas of intranet The uses of an Intranet are only limited by imagination. Some of the larger sectors where the Intranet can be easily and success fu

Connection to packet switches, CONNECTION TO PACKET SWITCHES:  A packe...

CONNECTION TO PACKET SWITCHES:  A packet switch many join to devices and to other packet switches. But the speeds are different in both parts. There are typically high-speed j

What is primary and secondary ring - fddi, What is primary and secondary ri...

What is primary and secondary ring One of the two FDDI rings is known as the primary ring; the other is called the secondary ring. The primary ring is utilized for data tra

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