Previous: Temporary entry and exit from QDP, Up: QDP Functions


4.9 Optimization Calls

The following procedures are included to aid in optimization of the QDP implementation

Marking discarded data

Syntax void QDP_discard_T(Type *a);


Meaning Indicates data in a is no longer needed.


Type I, R, C, V, H, D, M, P


Example QDP_discard_M(utemp);

The field is not destroyed and memory is not released. For that purpose, see QDP_destroy. This call allows the implementation to ignore the data dependency that may have been created from a shift which allows the shift to be efficiently reused later. It is a runtime error to attempt to use discarded data as an rvalue (source operand or incremented destination) in any subsequent operation. However, once the field is used as an lvalue (fully replaced destination), data integrity is automatically reinstated.

This should be called on the result of a shift once the result is no longer needed. It is safe to call it for any field as long as the data is no longer needed. It is highy recommended for the sake of efficiency that one always call this as soon as the result of a shift is no longer needed. It can also be used to make sure that a field is not being used elsewhere without first being set since using a discarded field without first setting it produces an error.

Block size operations

Syntax int QDP_get_block_size(void);


Meaning Returns the block size.

Syntax void QDP_set_block_size(int bs);


Meaning Sets the block size.

These functions allow one to set the block size used for the operations on arrays of QDP fields. Instead of running over all sites of each field individually, it can run over a few sites for each field in turn and then move to the next few sites on each field and so on until all sites are done. The number of sites done at a time is determined by the block size.

Memory alignment

Syntax int QDP_get_mem_align(void);


Meaning Returns the default memory alignment.

Syntax void QDP_set_mem_align(int align);


Meaning Sets the default memory alignment.

Some architectures might perform better for fields with certain alignments. This allows one to set the default alignment used when fields are created. It only affects newly created fields. Currently the default is set to 16 bytes if not set by the user which should be sufficient for most current platforms. It is expected that the QDP library will automatically use whatever value is necessary to utilize the optimized QLA routines for architectures which QLA has been optimized for. Therefore the user normally would not need to set this and it is recommended that they don't unless they specifically find it useful for a platform not already optimized in QLA. The user can also use the macro QDP_ALIGN_DEFAULT to specify the default alignment provided by QMP for that machine.

Memory attributes

Syntax int QDP_get_mem_flags(void);


Meaning Returns the default memory flags

Syntax void QDP_set_mem_flags(int flags);


Meaning Sets the default memory flags


Example QDP_set_mem_flags(QDP_MEM_FAST|QDP_MEM_COMMS);

This allows the user to set the characteristics of the memory used for newly created fields if the architecture supports them. The QDP memory flags have the same meaning as the corresponding QMP flags. The integer value is the combination (bitwise or) of the flags given below. The actual effect of each combination is specific to the implementation and the architecture.


Memory Flag Meaning


QDP_MEM_NONCACHE Use noncached memory.
QDP_MEM_COMMS Use memory that is optimized for communucations.
QDP_MEM_FAST Use fastest memory available (such as EDRAM on QCDOC).
QDP_MEM_DEFAULT Use default value for architecture (from QMP).