protected override void Initialize(IGridConfig gridCfg, Matrix <Cell> input) { _matrix = input; (_matrix.Height == _matrix.Width).AssertTrue(); (gridCfg.GridDim == null && gridCfg.BlockDim == null).AssertTrue(); gridCfg.SetDims(new dim3(1), new dim3(64)); }
protected override void Initialize(IGridConfig gridCfg, float[,] a, float[,] b) { _a = a; _b = b; (_a.Width() == _b.Height()).AssertTrue(); _c = new float[a.Height(), b.Width()]; var blockDim = new dim3(16, 16, 1); var gridDim = new dim3((int)Math.Ceil(1.0 * _b.Width() / 16), (int)Math.Ceil(1.0 * _a.Height() / 16), 1); gridCfg.SetDims(gridDim, blockDim); }
protected override void Initialize(IGridConfig gridCfg, float[,] a, float[,] b) { (a.Width() == b.Height()).AssertTrue(); _a = a; _b = b; _c = new float[_a.Height(), _b.Width()]; if (gridCfg.GridDim != null && gridCfg.BlockDim != null) { return; } (gridCfg.GridDim == null ^ gridCfg.BlockDim == null).AssertFalse(); const int defaultBlockSize = 16; var blockDim = gridCfg.BlockDim ?? new dim3(Min(_b.Width(), defaultBlockSize), Min(_a.Height(), defaultBlockSize)); var gridDim = gridCfg.GridDim ?? new dim3((int)Ceilf(1f * _b.Width() / blockDim.X), (int)Ceilf(1f * _a.Height() / blockDim.Y)); gridCfg.SetDims(gridDim, blockDim); }