本文整理汇总了C#中ComputeCommandQueue.Unmap方法的典型用法代码示例。如果您正苦于以下问题:C# ComputeCommandQueue.Unmap方法的具体用法?C# ComputeCommandQueue.Unmap怎么用?C# ComputeCommandQueue.Unmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComputeCommandQueue
的用法示例。
在下文中一共展示了ComputeCommandQueue.Unmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunInternal
protected override void RunInternal()
{
ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.Profiling);
Console.WriteLine("Original content:");
Random rand = new Random();
int count = 6;
long[] bufferContent = new long[count];
for (int i = 0; i < count; i++)
{
bufferContent[i] = (long)(rand.NextDouble() * long.MaxValue);
Console.WriteLine("\t" + bufferContent[i]);
}
ComputeBuffer<long> buffer = new ComputeBuffer<long>(context, ComputeMemoryFlags.CopyHostPointer, bufferContent);
IntPtr mappedPtr = commands.Map(buffer, false, ComputeMemoryMappingFlags.Read, 0, bufferContent.Length, null);
commands.Finish();
Console.WriteLine("Mapped content:");
for (int i = 0; i < bufferContent.Length; i++)
{
IntPtr ptr = new IntPtr(mappedPtr.ToInt64() + i * sizeof(long));
Console.WriteLine("\t" + Marshal.ReadInt64(ptr));
}
commands.Unmap(buffer, ref mappedPtr, null);
}
示例2: Run
public void Run(ComputeContext context, TextWriter log)
{
try
{
ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None);
log.WriteLine("Original content:");
Random rand = new Random();
int count = 6;
long[] bufferContent = new long[count];
for (int i = 0; i < count; i++)
{
bufferContent[i] = (long)(rand.NextDouble() * long.MaxValue);
log.WriteLine("\t" + bufferContent[i]);
}
ComputeBuffer<long> buffer = new ComputeBuffer<long>(context, ComputeMemoryFlags.CopyHostPointer, bufferContent);
IntPtr mappedPtr = commands.Map(buffer, true, ComputeMemoryMappingFlags.Read, 0, bufferContent.Length, null);
log.WriteLine("Mapped content:");
for (int i = 0; i < bufferContent.Length; i++)
{
IntPtr ptr = new IntPtr(mappedPtr.ToInt64() + i * sizeof(long));
log.WriteLine("\t" + Marshal.ReadInt64(ptr));
}
commands.Unmap(buffer, ref mappedPtr, null);
// wait for the unmap to happen
commands.Finish();
// cleanup buffer
buffer.Dispose();
// cleanup commands
commands.Dispose();
}
catch (Exception e)
{
log.WriteLine(e.ToString());
}
}
示例3: Run
public static void Run(TextWriter log, ComputeContext context)
{
StartTest(log, "Dummy test");
try
{
ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None);
log.WriteLine("Original content:");
Random rand = new Random();
int count = 6;
long[] bufferContent = new long[count];
for (int i = 0; i < count; i++)
{
bufferContent[i] = (long)(rand.NextDouble() * long.MaxValue);
log.WriteLine("\t" + bufferContent[i]);
}
ComputeBuffer<long> buffer = new ComputeBuffer<long>(context, ComputeMemoryFlags.CopyHostPointer, bufferContent);
IntPtr mappedPtr = commands.Map(buffer, false, ComputeMemoryMappingFlags.Read, 0, bufferContent.Length, null);
commands.Finish();
log.WriteLine("Mapped content:");
for (int i = 0; i < bufferContent.Length; i++)
{
IntPtr ptr = new IntPtr(mappedPtr.ToInt64() + i * sizeof(long));
log.WriteLine("\t" + Marshal.ReadInt64(ptr));
}
commands.Unmap(buffer, ref mappedPtr, null);
}
catch (Exception e)
{
log.WriteLine(e.ToString());
}
EndTest(log, "Dummy test");
}