Пример #1
0
        public static KpzNode DeserializeFromUInt32(uint value)
        {
            KpzNode node = new KpzNode();

            node.dx = (value & 1) != 0;
            node.dy = (value & 2) != 0;
            return(node);
        }
Пример #2
0
 /// <summary>Pull table from the FPGA.</summary>
 public static void CopyFromSimpleMemoryToGrid(KpzNode[,] gridDst, SimpleMemory memorySrc)
 {
     for (int x = 0; x < KpzKernels.GridWidth; x++)
     {
         for (int y = 0; y < KpzKernels.GridHeight; y++)
         {
             gridDst[x, y] = KpzNode.DeserializeFromUInt32(memorySrc.ReadUInt32(KpzKernels.MemIndexGrid + y * KpzKernels.GridWidth + x));
         }
     }
 }
Пример #3
0
 /// <summary>Push table into FPGA.</summary>
 public static void CopyFromGridToSimpleMemory(KpzNode[,] gridSrc, SimpleMemory memoryDst)
 {
     for (int x = 0; x < KpzKernels.GridHeight; x++)
     {
         for (int y = 0; y < KpzKernels.GridWidth; y++)
         {
             KpzNode node = gridSrc[x, y];
             memoryDst.WriteUInt32(KpzKernels.MemIndexGrid + y * KpzKernels.GridWidth + x, node.SerializeToUInt32());
         }
     }
 }
 /// <summary>Pull table from the FPGA.</summary>
 public static void CopyFromSimpleMemoryToGrid(KpzNode[,] gridDst, SimpleMemory memorySrc)
 {
     for (int x = 0; x < KpzKernelsParallelizedInterface.GridSize; x++)
     {
         for (int y = 0; y < KpzKernelsParallelizedInterface.GridSize; y++)
         {
             gridDst[x, y] = KpzNode.DeserializeFromUInt32(
                 memorySrc.ReadUInt32(KpzKernelsParallelizedInterface.MemIndexGrid + y * KpzKernelsParallelizedInterface.GridSize + x));
         }
     }
 }
 /// <summary>Push table into FPGA.</summary>
 public static void CopyFromGridToSimpleMemory(KpzNode[,] gridSrc, SimpleMemory memoryDst)
 {
     for (int x = 0; x < KpzKernelsParallelizedInterface.GridSize; x++)
     {
         for (int y = 0; y < KpzKernelsParallelizedInterface.GridSize; y++)
         {
             KpzNode node = gridSrc[x, y];
             memoryDst.WriteUInt32(KpzKernelsParallelizedInterface.MemIndexGrid + y * KpzKernelsParallelizedInterface.GridSize + x, node.SerializeToUInt32());
         }
     }
 }
Пример #6
0
 /// <summary>Make a deep copy of a grid (2D <see cref="KpzNode" /> array).</summary>
 private static KpzNode[,] CopyOfGrid(KpzNode[,] Grid)
 {
     KpzNode[,] toReturn = new KpzNode[Grid.GetLength(0), Grid.GetLength(1)];
     for (int x = 0; x < Grid.GetLength(0); x++)
     {
         for (int y = 0; y < Grid.GetLength(1); y++)
         {
             toReturn[x, y]    = new KpzNode();
             toReturn[x, y].dx = Grid[x, y].dx;
             toReturn[x, y].dy = Grid[x, y].dy;
         }
     }
     return(toReturn);
 }
Пример #7
0
 /// <summary>
 /// Fill grid with a pattern that already contains pyramids and holes, so the KPZ algorithm can work on it.
 /// </summary>
 public void InitializeGrid()
 {
     for (int x = 0; x < GridWidth; x++)
     {
         for (int y = 0; y < GridHeight; y++)
         {
             Grid[x, y]    = new KpzNode();
             Grid[x, y].dx = (bool)((x & 1) != 0);
             Grid[x, y].dy = (bool)((y & 1) != 0);
         }
     }
     if (_enableStateLogger)
     {
         StateLogger.AddKpzAction("InitializeGrid", Grid);
     }
 }
Пример #8
0
        /// <summary>It fills the <see cref="Grid" /> with random data.</summary>
        public void RandomizeGrid()
        {
            for (int x = 0; x < GridWidth; x++)
            {
                for (int y = 0; y < GridHeight; y++)
                {
                    Grid[x, y]    = new KpzNode();
                    Grid[x, y].dx = _random.Next(0, 2) == 0;
                    Grid[x, y].dy = _random.Next(0, 2) == 0;
                }
            }

            if (_enableStateLogger)
            {
                StateLogger.AddKpzAction("RandomizeGrid", Grid);
            }
        }