Initial commit.

This commit is contained in:
2017-10-26 19:57:24 +02:00
commit 9ce8b5485d
1090 changed files with 47036 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
#ifndef MOC_INTERNAL_CORE_PPU_H_
#define MOC_INTERNAL_CORE_PPU_H_
#include <stdint.h>
#include <libspe2.h>
#include <pthread.h>
#include "../imoc_core.h"
#include "../../ppu/moc.h"
/**
* \addtogroup internal_core
**/
//@{
/**
* @name PPU only
**/
//@{
/**
* Node-handle structure.
*
* \note PPU only
*
* Information each node knowns about himself and the world.
**/
typedef struct moc_node_handle_ppu_struct
{
uint8_t rank; /**< rank of node */
uint8_t comm_size; /**< number of overall processes */
uint8_t queue_size; /**< Size of a message-queue */
volatile moc_message_envelope_t* message_queue_base; /**< base-address of own message-queues */
volatile moc_message_status_t* status_array_base; /**< base-address of own message-status-array */
void* buffer_base; /**< base-address of own buffer */
uint32_t buffer_size; /**< size of own buffer */
volatile uint32_t* signal_area; /**< address of own signal-area */
volatile moc_process_t* moc_process_list; /**< list of all other MOC-processes
(index is rank of process) */
} moc_node_handle_ppu_t; /**< typedef of \ref moc_node_handle_ppu_struct */
/**
* Information each node knowns about himself and the world.
*
* \note PPU only
*
**/
moc_node_handle_ppu_t node_handle;
//@}
//@}
/**
* \addtogroup internal_spu_thread SPU-Thread Management
*
* \note PPU only
**/
//@{
/**
* SPU-Thread structure.
*
* \note PPU only
*
* Stores information about the SPU-Threads the managing PPU-Process
* needs to know.
**/
typedef struct moc_spu_thread_struct
{
uint8_t rank; /**< rank of SPU-thread */
pthread_t pthread; /**< PThread-handle <*/
spe_context_ptr_t speid; /**< SPE-Context */
spe_stop_info_t stop_info; /**< Error-Information */
uint32_t spe_entry_adress; /**< Spe-entry-address */
void *argp; /**< effective address of user-defined information
in main-memory */
void *envp; /**< Pointer to environment information */
void* buffer_base; /**< base-address of the SPU-Thread's buffer */
uint32_t buffer_size; /**< size of the SPU-Thread's buffer */
uint64_t ls_base; /**< Effective Basis-Address of SPU's local-storage */
uint32_t queue_base_in_ls; /**< Address of message-queue in SPU's local-storage */
uint32_t status_base_in_ls; /**< Address of status-array in SPU's local-storage */
} moc_spu_thread_t; /**< typedef of \ref moc_spu_thread_struct */
/**
* actual number of SPU-Threads.
*
* \note PPU only
**/
uint8_t moc_spu_thread_count;
/**
* actual number of PPU-Threads.
*
* \note PPU only
**/
uint8_t moc_ppu_thread_count;
/**
* init buffer size
**/
uint32_t moc_spu_buffer_size;
/**
* init message-queue size
**/
uint8_t moc_spu_queue_size;
/**
* array of SPU-Threads.
*
* \note PPU only
**/
moc_spu_thread_t moc_spu_thread_list[MOC_SPU_THREAD_MAX];
/**
* PThread-function for creating SPU-Threads
**/
void* moc_spe_pthread_func(void *arg);
//@}
#endif /*MOC_INTERNAL_CORE_PPU_H_*/
+148
View File
@@ -0,0 +1,148 @@
#ifndef MOC_INTERNAL_DATA_TRANSFER_PPU_H_
#define MOC_INTERNAL_DATA_TRANSFER_PPU_H_
#include <stdint.h>
#include "../../moc.h"
/**
* \addtogroup internal_p2p_dma
**/
//@{
/**
* @name PPU-only
**/
//@{
/**
* Internal wrapper-function for a blocking DMA-get operation.
* Data can be of any size, constraints of low-level DMA-functions
* are dealt by this function.
* However data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source,
* but copies only size bytes of it to target. This means however that up
* to 15 bytes are read from an invalid location. As it is never written to
* them this should always be safe.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param target \b in local-address of buffer
* @param source \b in ea-address of data
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @return 0 when success otherwise error-code
**/
int IMOC_get_data(void* target, uint64_t source, uint32_t size, int dest);
/**
* Internal wrapper-function for a blocking DMA-put operation.
* Data-size should be a multiple of 16 because of low-level constraints, but
* there is no upper limit of transfer-size.
* Data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source, and copies
* it to target. This means however that up to 15 bytes are written to and invalid
* location, so if one wants to use it with invalid sizes precautions have to be taken
* in order to make it safe.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param source \b in local-address of data
* @param target \b in ea-address of buffer
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @return 0 when success otherwise error-code
**/
int IMOC_put_data(void* source, uint64_t target, uint32_t size, int dest);
/**
* Internal wrapper-function for a non-blocking DMA-get operation.
* Data can be of any size, constraints of low-level DMA-functions
* are dealt by this function.
* However data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source,
* but copies only size bytes of it to target. This means however that up
* to 15 bytes are read from an invalid location. As it is never written to
* them this should always be safe.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param target \b in local-address of buffer
* @param source \b in ea-address of data
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @param request \b out request-handle
* @return 0 when success otherwise error-code
**/
int IMOC_iget_data(void* target, uint64_t source, uint32_t size, uint32_t dest, imoc_dma_request* request);
/**
* Internal wrapper-function for a non-blocking DMA-put operation.
* Data-size should be a multiple of 16 because of low-level constraints, but
* there is no upper limit of transfer-size.
* Data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source, and copies
* it to target. This means however that up to 15 bytes are written to and invalid
* location, so if one wants to use it with invalid sizes precautions have to be taken
* in order to make it safe.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param source \b in local-address of data
* @param target \b in ea-address of buffer
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @param request \b out request-handle
* @return 0 when success otherwise error-code
**/
int IMOC_iput_data(void* source, uint64_t target, uint32_t size, uint32_t dest, imoc_dma_request* request);
/**
* Waits till a IMOC_iget_data or IMOC_iput_data is completed.
*
* @param request \b in request-handle
* @return 0 when success otherwise error-code
**/
int IMOC_wait_dma(imoc_dma_request* request);
/**
* Tests if a IMOC_iget_data or IMOC_iput_data is completed.
*
* @param request \b in request-handle
* @param flag \b out true if operation is completed
* @return 0 when success otherwise error-code
**/
int IMOC_test_dma(imoc_dma_request* request, int *flag);
/**
* Reserves a tag on the ppu, for communication with a given spu.
*
* @param speid \b id of spu to communicate with
* @return tag (0-14) when success otherwise error code
**/
int moc_tag_reserve(unsigned int speid);
/**
* Releases a reserved tag.
*
* @param speid \b id of spu for which the tag was reserved
* @param tag \b tag to be released
* @return 0 when success otherwise error-code
**/
int moc_tag_release(unsigned int speid, int tag);
//@}
//@}
#endif /*MOC_INTERNAL_DATA_TRANSFER_PPU_H_*/
+48
View File
@@ -0,0 +1,48 @@
#ifndef MOC_INTERNAL_ADDRESS_MACROS_PPU_H_
#define MOC_INTERNAL_ADDRESS_MACROS_PPU_H_
#include "../imoc_macros.h"
/**
* \addtogroup internal_am
**/
//@{
/**
* @name PPU-only
**/
//@{
/**
* LS-Address of own remote queue at node 'rank'.
*
* Address is of type uint32_t.
**/
#define IMOC_LS_REMOTE_QUEUE(proc) ( (proc > node_handle.rank) ? moc_spu_thread_list[proc-moc_ppu_thread_count].queue_base_in_ls+sizeof(moc_message_envelope_t)*node_handle.queue_size*node_handle.rank : moc_spu_thread_list[proc-moc_ppu_thread_count].queue_base_in_ls+sizeof(moc_message_envelope_t)*node_handle.queue_size*(node_handle.rank-1) )
/**
* LS-Address of own remote queue-entry at node 'rank'.
*
* Address is of type uint32_t.
**/
#define IMOC_LS_REMOTE_QUEUE_ENTRY(proc, index) ( (proc > node_handle.rank) ? moc_spu_thread_list[proc-moc_ppu_thread_count].queue_base_in_ls+sizeof(moc_message_envelope_t)*node_handle.queue_size*node_handle.rank+sizeof(moc_message_envelope_t)*(index) : moc_spu_thread_list[proc-moc_ppu_thread_count].queue_base_in_ls+sizeof(moc_message_envelope_t)*node_handle.queue_size*(node_handle.rank-1)+sizeof(moc_message_envelope_t)*(index) )
/**
* Effective Address of remote status-array entry at node 'rank'.
*
* Address is of type uint32_t
**/
#define IMOC_LS_REMOTE_STATUS_ENTRY(id, rank) ( moc_spu_thread_list[rank-moc_ppu_thread_count].status_base_in_ls+sizeof(moc_message_status_t)*(id) )
//@}
//@}
#endif /*MOC_INTERNAL_ADDRESS_MACROS_PPU_H_*/