コード例 #1
0
        /// <summary>
        /// Verifies the contents of the given memory buffer.
        /// </summary>
        /// <typeparam name="T">The element type.</typeparam>
        /// <param name="view">The target buffer.</param>
        /// <param name="expected">The expected values.</param>
        /// <param name="offset">The custom data offset to use (if any).</param>
        /// <param name="length">The custom data length to use (if any).</param>
        public void Verify <T>(
            ArrayView <T> view,
            T[] expected,
            int?offset = null,
            int?length = null)
            where T : unmanaged
        {
            var data       = view.GetAsArray(Accelerator.DefaultStream);
            var dataLength = length ?? data.Length;

            Assert.True(dataLength <= data.Length);
            Assert.Equal(dataLength, expected.Length);
            for (int i = offset ?? 0, e = dataLength; i < e; ++i)
            {
                Assert.Equal(expected[i], data[i]);
            }
        }
コード例 #2
0
ファイル: DebugViews.cs プロジェクト: m4rs-mt/ILGPU
 /// <summary>
 /// Returns the underlying data of the given view for debugging purposes.
 /// </summary>
 /// <param name="source">The source view.</param>
 /// <returns>The raw view data for debugging purposes.</returns>
 protected static T[] GetDebuggerData(ArrayView <T> source)
 {
     SyncDebuggerState(source);
     return(source.GetAsArray());
 }
コード例 #3
0
ファイル: DebugViews.cs プロジェクト: rpfeuti/ILGPU
 /// <summary>
 /// Constructs a new debug view.
 /// </summary>
 /// <param name="source">The source array view.</param>
 public DebugArrayView(ArrayView <T> source)
     : base(source.GetAsArray())
 {
 }