OP2/OP2-Common — pull request #41 by gihanmudalige (2012-08-31 09:32:29+00:00)
Title: Core temp dats

This pull request is to merge the temporary dats implementation in to the OP2 master branch.

A temporary op_dat must be declared on an already existing op_set and thus basically inherits the set size, including mpi halos for this set. The proposed API calls for declaring a temporary dat is:

op_dat op_decl_dat_temp ( op_set set, int dim, char const *type, T *data, char const * name )

All the arguments except data the same definition as in an op_decl_dat() call. "data" is a dummy variable with size dim*sizeof(datatype).

This is needed because the temporary dat is created internally and the user *does not* pass a block of data (from which the size of an element can be determined) when the temporary dat is created. The allocated bytes in the temporary dat is all initialized to zero (using calloc). The variable "data" may later be adapted to allow to indicate the value to which each element of the temporary op_dat should be initialized to (if other than 0).

There is no different in the internal implementation of a static op_dat or a temporary op_dat. Thus when creating a fresh temporary op_dat, if an old temporary op_dat or a static op_dat that has the same name, set, dim and size exists then the existing op_dat is returned, otherwise a new op_dat is created and returned.

The following API call will free up a matching temporary dat:

int op_free_dat_temp(op_dat dat)

If the temporary dat was successfully freed then the above call will return 1. Otherwise -1.

The implementation of temporary dats required several key modifications to the OP2 core library routines and structs:

1. The OP_dat_list is now implemented as a double linked list using the tail queue implementation in sys/queue.h
2. The usage of op_dat->index is now removed from all the mpi back-end routines (although the op_dat->index field remains in op_dat_core)
3. The mpi buffers are now part of op_dat_core
4. The op_dat comparison in plan construction is removed so that par_loops can reuse the paln when the same temporary dat is used.

To test the temporary dats implementation, a new implementation of the Airfoil application was created, with the p_res implemented as a temporary op_dat. The example application can be found under /apps/c/airfoil/airfoil_tempdats.