[OSA] some SHMEM Analyzer fixes

- Alias Analysis Bug fix - ensures that aliasing errors are reported only when
  there is a possibility of symmetric buffers getting modified.

- adjustments to call graph for SHMEM Analyzer programs.
    - no dashed edges,
    - change I/O to Remote Memory Accesses.

Contributors: Siddhartha, Dounia

git-svn-id: http://svn.open64.net/svnroot/open64@4116 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] support for FORM TEAM, CHANGE TEAM, END TEAM, and optimization fix

This adds some compiler and runtime support for FORM TEAM, CHANGE TEAM and END
TEAM statements, based on draft of TS 18508 (new parallel features). Presently
it does not handle coarray associations specified in the CHANGE TEAM
statement.

Also adds some front-end fixes for CRITICAL / END CRITICAL, and the
RESULT_IMAGE argument check for collective intrinsics.

Additionally, we prevent unsafe optimizations across image control statements
by adding forward and backward barriers around various library calls
corresponding to image control statements. For sync all, sync images, and sync
memory a forward and backward memory barrier is inserted. For lock and
critical a backward memory barrier is inserted. For unlock and end critical a
forward memory barrier is inserted.

Also, we modified the routine in the optimzer for adding MU and CHI nodes to the
added barriers so that it does this for local coarrays and F90 targets (both
of which may potentially be modified by another image). May want to consider
using named barriers instead to prevent overly restrictive semantics for these
barriers for non-coarray codes.

This updates patch level to 3.0.39 as well.

Contributors: Shiyao, Deepak

git-svn-id: http://svn.open64.net/svnroot/open64@4117 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] Defer coarray symbol lowering in back-end to expose more optimization

This commit reorganizes the back-end handling of coarrays in order to enable
more optimization opportunities. The key change is to defer lowering of save
and target coarrays, which gives the optimizers (in particular LNO) more
latitude to reorder code.

A few issues that remain TBD:
- Global-scope coarrays are being allocated space when they shouldn't be.
- Observed slow down for some codes when using allocatables

Contributor: Deepak

git-svn-id: http://svn.open64.net/svnroot/open64@4118 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] various runtime fixes for teams support

This adds various bug fixes for the symmetric heap deallocation routines in
the runtime, and for management of the common slot in comm_init.

It fixes support for predefined reductions and broadcasts within team
blocks.

The logic for how many work buffers to allocate for the reduce-to-all routine
is fixed.

It adds some logic for adjusting the heap size for the initial team, if it
happens to exceed the total available memory allocated for the symmetric heap.

Also, implements a Bruck algorithm for the all-gather operation performed
during FORM TEAM.

Contributors: Gracia, Deepak, Dounia

git-svn-id: http://svn.open64.net/svnroot/open64@4119 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] adds node-aware algorithms for barrier and reductions

For each team, the runtime maintains a list of images that belong to an
image's intra-node set, and also a list of leader images in the team.  Using
this, we implement alternative algorithms for barriers and reductions that are
node-aware or 2-level, which may be optionally used. The 2-level barriers may
be selected via an environment variable, and it will be used only within a
team block (otherwise, the barrier provided by the underlying runtime is
used). The 2-level reduction may also be selected with an environment
variable.

Contributors: Shiyao, Deepak, Dounia

git-svn-id: http://svn.open64.net/svnroot/open64@4120 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] SYNC TEAM, and fixes for teams and module declarations

This commits adds compiler and runtime support for SYNC TEAM statement.

Also, several fixes are added in this commit:

- fix for teams and sync all when using ARMCI, and fixes symbolic links in
  armci directory
- front-end fix for SYNC IMAGES
- updates some runtime interfaces for TEAM statements
- fix for implicit deallocation at end of team blocks
- fix for handling ALLOCATABLE declarations with TARGET attribute (the dope
  vector, rather than the data it points to, was getting stored in the RMA
  segment)
- adds necessary optimization barriers for new image control statements during
  back-end compilation
- front-end fix for FORM TEAM, CHANGE TEAM, END TEAM (IR line/column numbers)
- adds optional TEAM and/or TEAM_ID argument to THIS IMAGE, NUM IMAGES, and
  IMAGE_INDEX intrinsics
- fix team support for reduce-to-image routine
- fix to align statically declared coarrays to 16 bytes in RMA segment, in
  case compiler applied a vectorization optimization that requires this
- front-end fix for setting ARRAY_IDX (not sure why this works)
- fixes some potential memory leaks during FORM TEAM
- adds remote image checks for current team

Other things added:

- Support for changing back to initial team within a team block, by
  implementing a stack structure for teams and a hash table for checking if a
  dope vector's allocation has been freed or not.

- An environment variable, UHCAF_REDUCTION_2LEVEL, for enabling 2-level
  reduction algorithm (only used for all-reduce).

- Fix for module declarations:

    Static coarray or target variables declared in a module should be treated
    as having COMMON storage class and need to be mapped to a single location
    in the RMA segment. If such a variable is initialized, then it should
    require only a single mem copy from the .data segment into the
    corresponding memory in the RMA segment. The changes here allow us to
    achieve this.

    This also adds a fix for treating some variables that do not have
    ST_is_initialized set as initialized, when they contain dope vectors (dope
    vector have some initialized fields). This is currently overly
    conservative, which results in suboptimal memory usage since any
    coarrays/targets detected to be "initialized" retain a copy in .data as
    well as in the RMA segment.

    All of this can be avoided if we had a good runtime method for explicitly
    registering specified memory regions, which neither GASNet or ARMCI seem
    to provide at present.

Contributors: Deepak, Shiyao

git-svn-id: http://svn.open64.net/svnroot/open64@4121 ead328b1-e903-0410-a19d-eacee4b031f6
[OSA, CAF] barrier matching analysis for SHMEM, and some other stuff

This adds the barrier matching analysis done at ORNL in OpenUH main trunk.
Some additional fixes include:

- correcting the number of line of if instructions presenting unmatched
  barriers
- add the warning message of the barrier matching analysis to the generated
  html file

TODO for this:
- integrate analysis output into OSA visualization tool
- understand better the current limitations

Aditionally, we add support for GET_TEAM and TEAM_ID intrinsics, and fix the
team_id for the initial team to be -1, rather than 0. Note that for FORM TEAM,
the TEAM_ID argument needs to be a positive number.

Contributors: Swaroop, Dounia, Oscar, Deepak

git-svn-id: http://svn.open64.net/svnroot/open64@4122 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] support CO_REDUCE, 2-level broadcast, plus other stuff

This provides some initial support for CO_REDUCE, or a user-defined reduction
in CAF, based on the current draft for TS 18508 (new parallel features).
Currently it assumes that the arguments are passed by reference, and there is
still no front-end checking that the function is valid.

A 2-level broadcast implementation. It is selected with
UHCAF_COLLECTIVES_2LEVEL, which also enables the 2-level reduction
implementation. Requires more evaluation to see if the current approach is
actually good for performance.

We also add a fix for bad initialization of use associated function result.
This is necessary when there is a module which uses another module that
contains a function interface which returns a type that has initialized
components.

We rename coarray_allocatable_allocate_new_ to coarray_allocatable_allocate_,
and get rid of the old allocatable_allocate routine.  Also, this fixes a bug
in _DEALLOCATE where it would enter into libcaf deallocate routine even for
arrays of size 0, resulting in a fatal error. Now, we check for this.

Additionally:

- removes some of the buggy or old barrier algorithm implementations,
  and keeps just 3 that are known to work: a dissemination algorithm, and two
  2-level algorithms.

- renames an environment variable UHCAF_SYNC_ALL_ALGORITHM to
  UHCAF_TEAM_BARRIER_ALGORITHM

- adds --init-team-heap option to cafrun for specifying heap size for initial
  team

- adds --with-default-caf-initial-team-heap-size configure option for
  compiler (default is 20M)

- updates the cafrun --help-env output to show newly added environment
  variables available for our implementation

Contributor: Deepak

git-svn-id: http://svn.open64.net/svnroot/open64@4123 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] profiling/tracing for teams, fix collectives offset calculation

This adds profiling and diagnostic tracing support for teams, and fixes the
profiling instrumentation for dealloc routines.

Also, we fix the collectives offset calculated during comm_init based on
adjusted alignment for statics.

Also, updating Changelog for 3.0.39, and USING_CAF_SUPPORT.

Contributor: Deepak

git-svn-id: http://svn.open64.net/svnroot/open64@4124 ead328b1-e903-0410-a19d-eacee4b031f6
[CAF] fixing --default-caf-initial-team-heap-size configure option

git-svn-id: http://svn.open64.net/svnroot/open64@4125 ead328b1-e903-0410-a19d-eacee4b031f6