Exemple #1
0
        public async Task Can_execute_default_formula()
        {
            // Arrange:
            var platformId = GetPlatforms().First();
            var deviceId   = GetPlatformDevices(platformId).First();
            var contextId  = CreateContext(platformId, new[] { deviceId });
            var queueId    = CreateCommandQueue(contextId, deviceId);

            var srcBuffer = CreateBuffer <int>(contextId, 16);

            // Act:
            var alg     = new OclFormulaAlgorithms();
            var eventId = await alg.Formula(queueId, 4, 4, new OclBuffer <int>(srcBuffer));

            WaitForEvents(eventId);

            // Assert:
            var result      = new int[16];
            var readEventId = EnqueueReadBuffer(queueId, srcBuffer, true, 0, 16, result.AsSpan());

            WaitForEvents(readEventId);

            ReleaseContext(contextId);

            for (var i = 0; i < result.Length; i++)
            {
                result[i].Should().Be(i);
            }
        }
        public async Task Formula()
        {
            await _algorithms.Formula(_queueId, _width, _height,
                                      new OclBuffer <int>(_sourceBufferId));

            Finish(_queueId);
        }