예제 #1
0
        public static string Init(int[] inputs, uint span)
        {
            _span = span;
            _area = _span * _span;

            d_rands        = new IntPtr();
            d_gridA        = new IntPtr();
            d_gridB        = new IntPtr();
            d_energy       = new IntPtr();
            d_energyBlocks = new IntPtr();

            _cudaArray  = new CudaArray();
            _gridProcs  = new GridProcs();
            _randoProcs = new RandoProcs();

            var strRet = _cudaArray.ResetDevice();

            strRet = strRet + _randoProcs.MakeGenerator64(SEED);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_gridA, _area);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_energy, _area);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_energyBlocks, _area / 1024);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_gridB, _area);
            strRet = strRet + _cudaArray.CopyIntsToDevice(inputs, d_gridA, _area);
            strRet = strRet + _cudaArray.CopyIntsToDevice(inputs, d_gridB, _area);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_rands, _area);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_betas, 10);

            return(strRet);
        }
예제 #2
0
        public static string Init(int[] inputs, uint span, uint blockSize)
        {
            _span       = span;
            _block_size = blockSize;

            _area            = _span * _span;
            _blocks_per_span = span / blockSize;
            _blockCount      = _blocks_per_span * _blocks_per_span;

            d_indexRands = new IntPtr();
            d_grid       = new IntPtr();

            _cudaArray  = new CudaArray();
            _gridProcs  = new GridProcs();
            _randoProcs = new RandoProcs();

            var strRet = _cudaArray.ResetDevice();

            strRet = strRet + _randoProcs.MakeGenerator32(SEED);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_grid, _area);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_energy, _area);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_energyBlocks, _area / 1024);
            strRet = strRet + _cudaArray.CopyIntsToDevice(inputs, d_grid, _area);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_indexRands, _blockCount);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_tempRands, _blockCount);
            strRet = strRet + _gridProcs.Runk_Energy4(d_energy, d_grid, _span);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_betas, 5);

            return(strRet);
        }
예제 #3
0
        public static string Init(int[] inputs, uint span)
        {
            // init libs
            _cudaArray  = new CudaArray();
            _gridProcs  = new GridProcs();
            _randoProcs = new RandoProcs();

            // Set grid sizes
            _span = span;
            _area = _span * _span;

            // Set block and thread sizes
            _blockSize = (_span < MAXTHREADS) ? _span : MAXTHREADS;
            _gridSize  = _area / _blockSize;

            // Set memory sizes
            _mem_N    = sizeof(int) * (_area);
            _mem_rand = sizeof(double) * (3 * _area);
            _mem_1    = sizeof(int) * (1);
            _mem_measured_quantity = sizeof(int) * (_gridSize);
            _mem_measured_magnet   = sizeof(int) * (_gridSize);

            // Allocate device arrays
            d_rands = new IntPtr();
            d_grid  = new IntPtr();

            var strRet = _cudaArray.ResetDevice();

            strRet = strRet + _randoProcs.MakeGenerator64(SEED);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_grid, _area);
            strRet = strRet + _cudaArray.CopyIntsToDevice(inputs, d_grid, _area);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_rands, _area);

            return(strRet);
        }
예제 #4
0
        public static string Init(int[] inputs, uint span)
        {
            _span      = span;
            _area      = _span * _span;
            _backwards = false;

            d_In  = new IntPtr();
            d_Out = new IntPtr();

            _cudaArray = new CudaArray();
            _gridProcs = new GridProcs();

            var res = _cudaArray.MallocIntsOnDevice(ref d_In, _area);

            res = res + _cudaArray.CopyIntsToDevice(inputs, d_In, _area);
            res = res + _cudaArray.MallocIntsOnDevice(ref d_Out, _area);

            return(res);
        }
예제 #5
0
        public static string Init(float[] temp_inputs, int[] flip_inputs, uint span, uint blockSize, int seed)
        {
            _span       = span;
            _block_size = blockSize;

            _area            = _span * _span;
            _blocks_per_span = span / blockSize;
            _blockCount      = _blocks_per_span * _blocks_per_span;

            d_flipData = new IntPtr();
            d_tempData = new IntPtr();

            d_flipRands  = new IntPtr();
            d_indexRands = new IntPtr();
            d_threshes   = new IntPtr();

            _cudaArray  = new CudaArray();
            _gridProcs  = new GridProcs();
            _randoProcs = new RandoProcs();

            var strRet = _cudaArray.ResetDevice();

            strRet = strRet + _randoProcs.MakeGenerator32(seed);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_tempData, _area);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_heatBlocks, _area / 1024);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_flipData, _area);

            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_indexRands, _blockCount);
            strRet = strRet + _cudaArray.MallocIntsOnDevice(ref d_flipRands, _blockCount);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_threshes, _allTempSteps);

            strRet = strRet + _cudaArray.CopyIntsToDevice(flip_inputs, d_flipData, _area);
            strRet = strRet + _cudaArray.CopyFloatsToDevice(temp_inputs, d_tempData, _area);


            var res9 = new int[_area];

            strRet = strRet + _cudaArray.CopyIntsFromDevice(res9, d_flipData, _area);

            return(strRet);
        }
예제 #6
0
        public static string Init(float[] inputs, uint span)
        {
            _span = span;
            _area = _span * _span;

            d_gridA = new IntPtr();
            d_gridB = new IntPtr();

            _cudaArray  = new CudaArray();
            _gridProcs  = new GridProcs();
            _randoProcs = new RandoProcs();

            var strRet = _cudaArray.ResetDevice();

            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_gridA, _area);
            strRet = strRet + _cudaArray.MallocFloatsOnDevice(ref d_gridB, _area);
            strRet = strRet + _cudaArray.CopyFloatsToDevice(inputs, d_gridA, _area);
            strRet = strRet + _cudaArray.CopyFloatsToDevice(inputs, d_gridB, _area);

            return(strRet);
        }