swps3
DynProgr_SPE.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 2007-2008 ETH Zürich, Institute of Computational Science
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation
10  * files (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use,
12  * copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following
15  * conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  */
29 
30 #ifndef DYNPROGR_SPE_H_
31 #define DYNPROGR_SPE_H_
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <sys/types.h>
38 
39 #define TOTAL_MEMORY 200000
40 #define MAX_TRANSFER 16384
41 
42 #define __ALIGNED__ __attribute__((__aligned__(16)))
43 #define ALIGN16(x) (((x)+15)&(-16))
44 #define ALIGN32(x) (((x)+31)&(-32))
45 /* This structs need to use long long instead of type* as *
46  * pointer, because SPE is 32 bit and PPE 64 */
47 
48 /*All types should be less than 16 */
49 #define SPE_ALIGNMENT_TYPE_MASK 0xf
50 #define SPE_ALIGNMENT_TYPE_DOUBLE 5
51 #define SPE_ALIGNMENT_TYPE_FLOAT 4
52 #define SPE_ALIGNMENT_TYPE_INT 3
53 #define SPE_ALIGNMENT_TYPE_SHORT 2
54 #define SPE_ALIGNMENT_TYPE_BYTE 1
55 
56 /* 16 is the special flag for the precalculated profile version */
57 #define SPE_ALIGNMENT_PROFILE 16
58 
59 typedef unsigned long long ppu_addr_t;
60 
61 typedef struct{
62  int32_t len;
63  int32_t blockSize;
64  double min;
65  double max;
66  ppu_addr_t addr;
67 } SPEProfile;
68 
69 typedef struct{
70  int32_t len;
71  ppu_addr_t addr;
72 } SPESequence;
73 
74 typedef struct{
75  double min;
76  double max;
77  ppu_addr_t addr;
78 } SPEMatrix;
79 
86 };
87 
94 };
95 
96 static const int dataSize[5] = {1,2,4,sizeof(float),sizeof(double)};
97 
98 typedef struct{
99  int32_t command;
100  union {
101  struct {
102  int32_t datatype;
103  int32_t dbMaxLen;
104  double fixedDel;
105  double incDel;
106  } INIT;
107  struct {
110  } CREATE_PROFILE;
111  struct {
112  ppu_addr_t addr;
113  int32_t blockSize; /*out*/
114  } PUT_PROFILE;
115  struct {
117  } GET_PROFILE;
118  struct {
120  double result; /*out*/
121  } ALIGN;
122  } data;
123 } SPECommand;
124 
125 /* Memory allocation functions */
126 void * alloc( int n );
127 void reset();
128 int memRemaining();
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif