OpenNet
Kernel.h
Aller à la documentation de ce fichier.
1 
2 // Product OpenNet
3 
7 
8 #pragma once
9 
10 // Standard int types
12 
13 #define uint32_t unsigned int
14 #define uint8_t unsigned char
15 
16 // Includes
18 
19 // ===== Includes ===========================================================
20 
21 #ifdef _OPEN_NET_CUDA_
22  #include <OpenNetK/Kernel_CUDA.h>
23 #endif
24 
25 #ifdef _OPEN_NET_OPEN_CL_
26  #include <OpenNetK/Kernel_OpenCL.h>
27 #endif
28 
29 #include <OpenNetK/Types.h>
30 
31 // Macros
33 
34 // ===== Assert =============================================================
35 
42 #define OPEN_NET_ASSERT(C) if (!(C)) { lEvents |= OPEN_NET_BUFFER_ASSERT_FAILURE; }
43 
44 // ===== Function ===========================================================
45 
54 #define OPEN_NET_FUNCTION_DECLARE(F) \
55  OPEN_NET_DEVICE void F( OPEN_NET_GLOBAL OpenNet_BufferHeader * aBufferHeader )
56 
63 #define OPEN_NET_FUNCTION_BEGIN \
64  OPEN_NET_GLOBAL_MEMORY_FENCE; \
65  if ( 0 == ( OPEN_NET_BUFFER_PROCESSED & aBufferHeader->mEvents ) ) \
66  { \
67  OPEN_NET_SHARED unsigned int lEvents; \
68  OPEN_NET_GLOBAL unsigned char * lBase = (OPEN_NET_GLOBAL unsigned char *)( aBufferHeader ); \
69  OPEN_NET_GLOBAL OpenNet_PacketInfo * lPacketInfo = (OPEN_NET_GLOBAL OpenNet_PacketInfo *)( lBase + aBufferHeader->mPacketInfoOffset_byte ); \
70  lEvents = 0; \
71  lPacketInfo += OPEN_NET_PACKET_INDEX; \
72  if ( 0 == lPacketInfo->mSendTo ) \
73  {
74 
81 #define OPEN_NET_FUNCTION_END \
82  } \
83  OPEN_NET_GLOBAL_MEMORY_FENCE; \
84  if ( 0 == OPEN_NET_PACKET_INDEX ) \
85  { \
86  aBufferHeader->mEvents = lEvents | OPEN_NET_BUFFER_PROCESSED; \
87  } \
88  OPEN_NET_GLOBAL_MEMORY_FENCE; \
89  }
90 
91 // ===== Kernel =============================================================
92 
99 #define OPEN_NET_KERNEL_DECLARE \
100  OPEN_NET_KERNEL void Filter( OPEN_NET_GLOBAL OpenNet_BufferHeader * aBufferHeader )
101 
108 #define OPEN_NET_KERNEL_BEGIN \
109  OPEN_NET_GLOBAL_MEMORY_FENCE; \
110  if ( 0 == ( OPEN_NET_BUFFER_PROCESSED & aBufferHeader->mEvents ) ) \
111  { \
112  OPEN_NET_SHARED unsigned int lEvents; \
113  OPEN_NET_GLOBAL unsigned char * lBase = (OPEN_NET_GLOBAL unsigned char *)( aBufferHeader ); \
114  OPEN_NET_GLOBAL OpenNet_PacketInfo * lPacketInfo = (OPEN_NET_GLOBAL OpenNet_PacketInfo *)( lBase + aBufferHeader->mPacketInfoOffset_byte ); \
115  lEvents = 0; \
116  lPacketInfo += OPEN_NET_PACKET_INDEX; \
117  if ( 0 == lPacketInfo->mSendTo ) \
118  {
119 
126 #define OPEN_NET_KERNEL_END \
127  } \
128  OPEN_NET_GLOBAL_MEMORY_FENCE; \
129  if ( 0 == OPEN_NET_PACKET_INDEX ) \
130  { \
131  aBufferHeader->mEvents = lEvents | OPEN_NET_BUFFER_PROCESSED; \
132  } \
133  OPEN_NET_GLOBAL_MEMORY_FENCE; \
134  }
OpenNet_BufferHeader, OpenNet_PacketInfo (RT)