-
Notifications
You must be signed in to change notification settings - Fork 1
Changes in SIAL V2
basanders edited this page Sep 16, 2014
·
11 revisions
This page describes the changes in Sial V2
The Sialx1toSialx2 program in the util project helps with the conversion. See the readme file. The required changes are
- Blocks now use square brackets instead of parentheses. a(i,j,k,l) --> a[i,j,k,l]
- Upper and lower bounds of ranges are now separated by a colon instead of a comma. aoindex i = 1,norb --> aoindex i = 1:norb
- An int type has been added to the language (previously int variables had to be predefined). As a consequence, some programs that previously used scalars to hold what are really int values, may want to redefine the types of some variables. Coercion between int and scalar is not longer supported, but this can be achieved by explicit casts. ( (scalar)i or (int)x ). In the current implementation, a cast from scalar to int will round to the nearest int.
- request statements no longer require or allow the (previously ignored) hint parameter.
-
Contiguous local arrays. Previously, the only contiguously allocated arrays were static, which are required to contain the whole array, and exist for the entire lifetime of the sial program. Contiguous local arrays can contain multiple, contiguously allocated blocks of an array but need not include the entire array, and can be dynamically allocated and deallocate like normal local arrays. Contiguous local arrays are declared with the contiguous local modifier:
contiguous local loc1[i,j]
. Contiguous regions can be allocated with the allocate contiguous command:allocate contiguous loc1[3:4,3:4]
. Elsewhere in the sial program, contiguous local regions are referred to by giving the range for each index. The SIA runtime extracts the desired subregion: 'tmp[i,j] = loc1[i:i,j:j]' extracts the [i,j] block. Subregions are automatically extracted and inserted similar to the features offered for blocks of static arrays. The ranges of the indices are expressions (int values), rather than index names, so we could say 'loc1[i:i+1, j:j+1]' or 'loc1[1:norb, 1:1]. -
Expressions. Previously, expressions were limited in SIAL to binary expressions. So to add together x, y, and z, one would need two lines of code:
t = x + y
followed byr = t + z
. Now it is possible to say r = x + y + z, and use parentheses, etc as one can do in most programming languages. Operations where the result is a block remain exceptions. Each operation that results in a block must specify the destination, so these operations remain limited to binary operations. -
Scalar valued blocks. Blocks of arrays that are all simple indices, and thus actually a single value are interchangeable with scalars everywhere except contraction and tensor expressions. Thus, if
i
,j
, andk
are simple indices,b[i,j] * c[k]
is a contraction with result,r[i,j,k]
, not the multiplication of two scalars. On the other hand,x = .5 * b[i,j]
, wherex
is a scalar simply multiplies the scalar value ofb[i,j]
by.5
and assigns it tox
. -
Polymorphic print statements.
print
andprintln
now take any type of argument (including blocks) and have replaced print_int, print_index, etc. The module in the SIA runtime implementing these is easily replaced to provide custom formatting. - assert_same. The assert_same command takes a scalar variable as an argument. The SIA runtime compares the values of that variable at all of the workers and aborts the computation if they are not within a given tolerance. Then it sets the value at all workers to exactly the same value (currently the value of the master) before continuing.
- broadcast_static The broadcast_static command takes the name of a static array, and an int representing the MPI rank of the worker whose static array contents is broadcast to the other workers. This is a collective operation and cannot be inside a pardo loop. Also, note that rank zero is guaranteed to exist and be a worker in all sial programs. Using other values may result in a program that does not run in all situations.