Initial commit.
This commit is contained in:
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#ifndef MOC_H_PPU
|
||||
#define MOC_H_PPU
|
||||
|
||||
|
||||
#include "moc_dma_ppu.h"
|
||||
#include "moc_datatype_ppu.h"
|
||||
#include "../moc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <libspe2.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Maximum number of possible SPU-threads.
|
||||
**/
|
||||
#define MOC_SPU_THREAD_MAX 16
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup environment_startup
|
||||
**/
|
||||
//@{
|
||||
/**
|
||||
* @name PPU-only
|
||||
**/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Returns the number of available SPUs.
|
||||
*
|
||||
* \attention PPU-only
|
||||
*
|
||||
* \note Must be called before \ref MOC_Init
|
||||
*
|
||||
* \note This function should return the count of free SPUs. But this
|
||||
* doesn't really works. To get the available SPU-count the
|
||||
* function spe_cpu_info_get() from libspe2 with
|
||||
* SPE_COUNT_USABLE_SPES-flag is used. However this function can only
|
||||
* detect if a SPU-thread is used by the calling function. There seems
|
||||
* to be no means to detect SPU-thread used by other applications.
|
||||
*
|
||||
*
|
||||
* \param count \b out number of available SPUs
|
||||
* \retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* \retval ... error-code
|
||||
**/
|
||||
int MOC_Get_avail_spu_count(int* count);
|
||||
|
||||
/**
|
||||
* Returns the number of SPUs.
|
||||
*
|
||||
* \attention PPU-only
|
||||
*
|
||||
* \note Must be called before \ref MOC_Init
|
||||
*
|
||||
* \param count \b out SPU-count
|
||||
* \retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* \retval ... error-code
|
||||
**/
|
||||
int MOC_Get_max_spu_count(int* count);
|
||||
|
||||
/**
|
||||
* Adds a SPU-Thread.
|
||||
*
|
||||
* \attention PPU-only
|
||||
*
|
||||
* \note Must be called before calling \ref MOC_Init
|
||||
*
|
||||
* \note The order of executions defines the order of the ranks of the SPU-Threads
|
||||
*
|
||||
* \param phandle \b in Handle of the SPE-Program
|
||||
* \param argp \b in Pointer to some user-defined information in the main-memory
|
||||
* \retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* \retval MOC_ERR_BUFFER_OVERFLOW A Buffer-Overflow occured. Mosst likely you tried to add more
|
||||
* SPU-threads than defined by \ref MOC_SPU_THREAD_MAX.
|
||||
* \retval MOC_ERR_INTERN Internal Error
|
||||
**/
|
||||
int MOC_Add_spu_thread ( spe_program_handle_t* phandle, void* argp );
|
||||
|
||||
/**
|
||||
* Sets the size of the buffer used for buffered communication.
|
||||
*
|
||||
* \attention PPU-only
|
||||
*
|
||||
* \note Must be called before \ref MOC_Init
|
||||
*
|
||||
* \param size buffer-size
|
||||
* \return 0 if success, otherwise error-code
|
||||
**/
|
||||
int MOC_Set_buffer_size ( uint32_t size );
|
||||
|
||||
/**
|
||||
* Sets the size of the message-queues.
|
||||
*
|
||||
* \attention PPU-only
|
||||
*
|
||||
* \note Must be called before \ref MOC_Init
|
||||
*
|
||||
* \param size queue-size
|
||||
* \return 0 if success, otherwise error-code
|
||||
**/
|
||||
int MOC_Set_queue_size ( uint8_t size );
|
||||
|
||||
/**
|
||||
* Initialize the MPI execution environment.
|
||||
*
|
||||
* \attention PPU-only function
|
||||
*
|
||||
* \note All processes must call this routine before executing any MOC-routine.
|
||||
*
|
||||
* \param argc \b in Pointer to the number of arguments
|
||||
* \param argv \b in Pointer to the argument vector
|
||||
* \retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* \retval MOC_ERR_NO_MEMORY Insufficient Memory.
|
||||
* \retval MOC_ERR_INTERN Internal Error
|
||||
**/
|
||||
int MOC_Init ( int *argc, char ***argv );
|
||||
|
||||
//@}
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
#endif /*MOC_H_*/
|
||||
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#ifndef MOC_DATATYPE_PPU_H_
|
||||
#define MOC_DATATYPE_PPU_H_
|
||||
|
||||
#include "../moc_datatype.h"
|
||||
/**
|
||||
* \addtogroup p2p_datatype
|
||||
**/
|
||||
//@{
|
||||
/**
|
||||
* @name PPU-only
|
||||
**/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* C-Datatype long.
|
||||
* It has a size of 8 byte.
|
||||
* \attention On the SPU long has a size of 4 byte. So if
|
||||
* you are trying to send data of type long from the PPU to a
|
||||
* SPU or vice versa there will be an error.
|
||||
**/
|
||||
#define MOC_LONG ((MOC_Datatype)64+2)
|
||||
|
||||
/**
|
||||
* C-Datatype unsigned long.
|
||||
* It has a size of 8 byte.
|
||||
* \attention On the SPU unsigned long has a size of 4 byte. So if
|
||||
* you are trying to send data of type long from the PPU to a
|
||||
* SPU or vice versa there will be an error.
|
||||
**/
|
||||
#define MOC_UNSIGNED_LONG ((MOC_Datatype)64+3)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cell-specific Datatype vector bool char (vec_bchar16).
|
||||
* It has a size of 16 byte.
|
||||
* \note PPU-only. Is mapped to the SPU-Datatype vector unsigned char.
|
||||
**/
|
||||
#define MOC_VEC_BCHAR16 ((MOC_Datatype)128+0)
|
||||
|
||||
/**
|
||||
* Cell-specific Datatype vector bool short (vec_bshort8).
|
||||
* It has a size of 16 byte.
|
||||
* \note PPU-only. Is mapped to the SPU-Datatype vector unsigned short.
|
||||
**/
|
||||
#define MOC_VEC_BSHORT8 ((MOC_Datatype)128+1)
|
||||
|
||||
/**
|
||||
* Cell-specific Datatype vector pixel (vec_pixel8).
|
||||
* It has a size of 16 byte.
|
||||
* \note PPU-only. Is mapped to the SPU-Datatype vector unsigned short.
|
||||
**/
|
||||
#define MOC_VEC_PIXEL8 ((MOC_Datatype)128+1)
|
||||
|
||||
/**
|
||||
* Cell-specific Datatype vector bool int (vec_bint4).
|
||||
* It has a size of 16 byte.
|
||||
* \note PPU-only. Is mapped to the SPU-Datatype vector unsigned int.
|
||||
**/
|
||||
#define MOC_VEC_BINT4 ((MOC_Datatype)128+2)
|
||||
|
||||
|
||||
//@}
|
||||
//@}
|
||||
#endif /*MOC_DATATYPE_PPU_H_*/
|
||||
Executable
+119
@@ -0,0 +1,119 @@
|
||||
#ifndef MOC_DATA_TRANSFER_PPU_H_
|
||||
#define MOC_DATA_TRANSFER_PPU_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../moc.h"
|
||||
#include "moc_datatype_ppu.h"
|
||||
|
||||
/**
|
||||
* \addtogroup dma_access
|
||||
**/
|
||||
//@{
|
||||
/**
|
||||
* @name PPU-only
|
||||
**/
|
||||
//@{
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param target \b out pointer to buffer
|
||||
* @param source \b in local-store address of data
|
||||
* @param count \b in size of data in byte
|
||||
* @param datatype \b in Type of Elements
|
||||
* @param dest \b in rank of source spe
|
||||
* @retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* @retval ... error-code
|
||||
**/
|
||||
int MOC_Get_data(void* target, uint32_t source, int count,
|
||||
MOC_Datatype datatype, int dest);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param source \b in pointer to data
|
||||
* @param target \b in local-store address of buffer
|
||||
* @param count \b in size of data in byte
|
||||
* @param datatype \b in Type of Elements
|
||||
* @param src \b in rank of source-SPE
|
||||
* @retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* @retval ... error-code
|
||||
**/
|
||||
int MOC_Put_data(void* source, uint32_t target, int count,
|
||||
MOC_Datatype datatype, int src);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Operation-completion can be derived with MOC_Test and MOC_Wait.
|
||||
*
|
||||
* @param target \b out pointer to buffer
|
||||
* @param source \b in local-store address of data
|
||||
* @param count \b in size of data in byte
|
||||
* @param datatype \b in Type of Elements
|
||||
* @param dest \b in rank of source spe
|
||||
* @param request \b out communication request (handle)
|
||||
* @retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* @retval ... error-code
|
||||
**/
|
||||
int MOC_IGet_data(void* target, uint32_t source, int count,
|
||||
MOC_Datatype datatype, int dest, MOC_Request *request);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Operation-completion can be derived with MOC_Test and MOC_Wait.
|
||||
*
|
||||
* @param source \b in pointer to data
|
||||
* @param target \b in local-store address of buffer
|
||||
* @param count \b in size of data in byte
|
||||
* @param datatype \b in Type of Elements
|
||||
* @param src \b in rank of source-SPE
|
||||
* @param request \b out communication request (handle)
|
||||
* @retval MOC_SUCCESS No error; MPI routine completed successfully.
|
||||
* @retval ... error-code
|
||||
**/
|
||||
int MOC_IPut_data(void* source, uint32_t target, int count,
|
||||
MOC_Datatype datatype, int src, MOC_Request *request);
|
||||
|
||||
/**
|
||||
* Translates an effective-address of a SPU into the corresponding local-store address.
|
||||
*
|
||||
* @param ea \b in effective-address
|
||||
* @param rank \b in rank of SPU
|
||||
* @param ls \b out local-store address
|
||||
**/
|
||||
int MOC_Translate_EA_to_LS(uint64_t ea, int rank, uint32_t* ls);
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
* Waits till a MOC_IGet_data or IMOC_IPut_data is completed.
|
||||
*
|
||||
* @param request \b in request-handle
|
||||
* @return 0 when success otherwise error-code
|
||||
**/
|
||||
int MOC_Wait_data(MOC_Request* request);
|
||||
|
||||
/**
|
||||
* Tests if a MOC_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 MOC_Test_data(MOC_Request* request, int *flag);
|
||||
|
||||
//@}
|
||||
#endif /*MOC_DATA_TRANSFER_PPU_H_*/
|
||||
Reference in New Issue
Block a user