Files
2017-10-26 19:57:24 +02:00

142 lines
4.5 KiB
C
Executable File

#ifndef MOC_INTERNAL_ADDRESS_MACROS_H_
#define MOC_INTERNAL_ADDRESS_MACROS_H_
/**
* \addtogroup internal_am
**/
//@{
/**
* @name PPU & SPU
**/
//@{
/**
* Effective base-address of own remote queue at node 'rank'.
*
* Address is of type uint64_t
**/
#define IMOC_EA_REMOTE_QUEUE(proc) ( (proc > node_handle.rank) ? node_handle.moc_process_list[proc].inbox_queue_base+sizeof(moc_message_envelope_t)*node_handle.queue_size*node_handle.rank : node_handle.moc_process_list[proc].inbox_queue_base+sizeof(moc_message_envelope_t)*node_handle.queue_size*(node_handle.rank-1) )
/**
* Effective Base-Address of local queue responsible for node 'rank'.
*
* Address is of type moc_message_envelope_t*
**/
#define IMOC_LOCAL_QUEUE(proc) ( (proc < node_handle.rank) ? node_handle.message_queue_base+node_handle.queue_size*(proc) : node_handle.message_queue_base+node_handle.queue_size*(proc-1) )
/**
* Effective base-address of own remote queue-entry at node 'rank'.
*
* Address is of type uint64_t
**/
#define IMOC_EA_REMOTE_QUEUE_ENTRY(proc, index) ( (proc > node_handle.rank) ? node_handle.moc_process_list[proc].inbox_queue_base+sizeof(moc_message_envelope_t)*node_handle.queue_size*node_handle.rank+sizeof(moc_message_envelope_t)*(index) : node_handle.moc_process_list[proc].inbox_queue_base+sizeof(moc_message_envelope_t)*node_handle.queue_size*(node_handle.rank-1)+sizeof(moc_message_envelope_t)*(index) )
/**
* Effective Base-Address of local queue-entry responsible for node 'rank'.
*
* Address is of type moc_message_envelope_t*
**/
#define IMOC_LOCAL_QUEUE_ENTRY(proc, index) ( (proc < node_handle.rank) ? node_handle.message_queue_base+node_handle.queue_size*(proc)+(index) : node_handle.message_queue_base+node_handle.queue_size*(proc-1)+(index) )
/**
* Effective Address of remote status-array entry at node 'rank'.
*
* Address is of type uint64_t
**/
#define IMOC_EA_REMOTE_STATUS_ENTRY(id, rank) ( node_handle.moc_process_list[rank].stat_array_base+sizeof(moc_message_status_t)*(id) )
//@}
//@}
/**
* \addtogroup internal_tm
**/
//@{
/**
* Tests if invalid communicator in a send-operation.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_COMM_SEND(comm) if ( (comm) != MOC_COMM_WORLD && (comm) != MOC_COMM_SELF ) \
{ return MOC_ERR_COMM; }
/**
* Tests if invalid communicator in a recv-operation.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_COMM_RECV(comm) if ( (comm) != MOC_COMM_WORLD && (comm) != MOC_COMM_SELF ) \
{ return MOC_ERR_COMM; }
/**
* Tests if invalid tag in a send-operation.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_TAG_SEND(tag) if ( (tag) > 255 || (tag) < 0 ) \
{ return MOC_ERR_TAG; }
/**
* Tests if invalid tag in a recv-operation.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_TAG_RECV(tag) if ( (tag)!=MOC_ANY_TAG && ((tag) > 255 || (tag) < 0) ) \
{ return MOC_ERR_TAG; }
/**
* Tests if invalid rank.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_RANK(rank) if ( (rank) < 0 || (rank) >= node_handle.comm_size ) \
{ return MOC_ERR_RANK; }
/**
* Tests if invalid rank in a recv-operation.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_RANK_RECV(rank) if ( rank != MOC_ANY_SOURCE && ((rank) < 0 || (rank) >= node_handle.comm_size) ) \
{ return MOC_ERR_RANK; }
/**
* Tests if invalid byte-count in a recv-operation.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_BYTECOUNT(count) if ( (count) < 0 || (count) > MAX_MOC_MESSAGE_SIZE ) \
{ return MOC_ERR_COUNT; }
/**
* Tests if invalid buffer-pointer.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_BUFFER(buf) if ( (buf) == 0 ) \
{ return MOC_ERR_BUFFER; }
/**
* Tests if rank is MOC_PROC_NULL and returns with MOC_SUCCESS itself.
**/
#define IMOC_TEST_PROC_NULL(rank) if ((rank) == MOC_PROC_NULL ) \
{ return MOC_SUCCESS; }
/**
* Tests if rank is own rank and returns with MOC_SUCCESS itself.
**/
#define IMOC_TEST_PROC_SELF(proc) if ( (proc) == node_handle.rank ) \
{ return MOC_SUCCESS; }
/**
* Tests if address is 16-byte aligned.
* Calls return with appropriate error-code itself.
**/
#define IMOC_TEST_ALIGNMENT(address) if ( ((unsigned long)(address)) % 16 != 0 ) \
{ return MOC_ERR_BAD_ALIGNMENT; }
//@}
#endif /*MOC_INTERNAL_ADDRESS_MACROS_H_*/