DynProgr_SPE.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Copyright (c) 2007-2008 ETH Zürich, Institute of Computational Science
00007  *
00008  * Permission is hereby granted, free of charge, to any person
00009  * obtaining a copy of this software and associated documentation
00010  * files (the "Software"), to deal in the Software without
00011  * restriction, including without limitation the rights to use,
00012  * copy, modify, merge, publish, distribute, sublicense, and/or sell
00013  * copies of the Software, and to permit persons to whom the
00014  * Software is furnished to do so, subject to the following
00015  * conditions:
00016  *
00017  * The above copyright notice and this permission notice shall be
00018  * included in all copies or substantial portions of the Software.
00019  *
00020  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00022  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00023  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00024  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00025  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027  * OTHER DEALINGS IN THE SOFTWARE.
00028  */
00029 
00030 #ifndef DYNPROGR_SPE_H_
00031 #define DYNPROGR_SPE_H_
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 #include <sys/types.h>
00038 
00039 #define TOTAL_MEMORY 200000
00040 #define MAX_TRANSFER 16384
00041 
00042 #define __ALIGNED__ __attribute__((__aligned__(16)))
00043 #define ALIGN16(x)    (((x)+15)&(-16))
00044 #define ALIGN32(x)    (((x)+31)&(-32))
00045 /* This structs need to use long long instead of type* as *
00046  * pointer, because SPE is 32 bit and PPE 64              */
00047 
00048 /*All types should be less than 16 */
00049 #define SPE_ALIGNMENT_TYPE_MASK 0xf
00050 #define SPE_ALIGNMENT_TYPE_DOUBLE 5
00051 #define SPE_ALIGNMENT_TYPE_FLOAT  4
00052 #define SPE_ALIGNMENT_TYPE_INT    3
00053 #define SPE_ALIGNMENT_TYPE_SHORT  2
00054 #define SPE_ALIGNMENT_TYPE_BYTE   1
00055 
00056 /* 16 is the special flag for the precalculated profile version */
00057 #define SPE_ALIGNMENT_PROFILE  16
00058 
00059 typedef unsigned long long ppu_addr_t;
00060 
00061 typedef struct{
00062     int32_t len;
00063     int32_t blockSize;
00064     double min;
00065     double max;
00066     ppu_addr_t addr;
00067 } SPEProfile;
00068 
00069 typedef struct{
00070     int32_t len;
00071     ppu_addr_t addr;
00072 } SPESequence;
00073 
00074 typedef struct{
00075     double min;
00076     double max;
00077     ppu_addr_t addr;
00078 } SPEMatrix;
00079 
00080 enum SPECommands{
00081         SPE_CMD_INIT,
00082         SPE_CMD_CREATE_PROFILE,
00083         SPE_CMD_PUT_PROFILE,
00084         SPE_CMD_GET_PROFILE,
00085         SPE_CMD_ALIGN
00086 };
00087 
00088 enum SPEDatatypes{
00089         SPE_DATA_INT8 = 0,
00090         SPE_DATA_INT16 = 1,
00091         SPE_DATA_INT32 = 2,
00092         SPE_DATA_FLOAT = 3,
00093         SPE_DATA_DOUBLE = 4
00094 };
00095 
00096 static const int dataSize[5] = {1,2,4,sizeof(float),sizeof(double)};
00097 
00098 typedef struct{
00099         int32_t command;
00100         union {
00101                 struct {
00102                         int32_t datatype;
00103                         int32_t dbMaxLen;
00104                         double fixedDel;
00105                         double incDel;
00106                 } INIT;
00107                 struct {
00108                         SPESequence query;
00109                         SPEMatrix matrix;
00110                 } CREATE_PROFILE;
00111                 struct {
00112                         ppu_addr_t addr;
00113                         int32_t blockSize; /*out*/
00114                 } PUT_PROFILE;
00115                 struct {
00116                         SPEProfile profile;
00117                 } GET_PROFILE;
00118                 struct {
00119                         SPESequence db;
00120                         double result; /*out*/
00121                 } ALIGN;
00122         } data;
00123 } SPECommand;
00124 
00125 /* Memory allocation functions */
00126 void * alloc( int n );
00127 void reset();
00128 int memRemaining();
00129 
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133 
00134 #endif

Generated on Thu Jun 5 12:44:37 2008 for swps3 by  doxygen 1.5.4