c++-amp - 使用 C++ AMP 的退出代码中的问题
问题描述
环境:Visual Studio 2017,Windows 10 版本。1709.编译方式:发布。
当我打电话时:
accelerator_view acc_view = accelerator().default_view;
引发异常(请参见下图链接),但之后代码执行良好。但是当可执行进程退出并且我调用时:
::GetExitCodeProcess(hChildProcess, &retVal);
从调用者进程中,它不是返回 0,而是在 retVal 中返回一个垃圾值。挖掘源代码,问题似乎出在下面的代码片段中(SchedulerBase.cpp,第 149 行)
// Auto-reset event that is not signalled initially
m_hThrottlingEvent = platform::__CreateAutoResetEvent();
// Use a trampoline for UMS
if (!RegisterWaitForSingleObject(&m_hThrottlingWait, m_hThrottlingEvent, SchedulerBase::ThrottlerTrampoline, this, INFINITE, WT_EXECUTEDEFAULT))
{
throw scheduler_resource_allocation_error(HRESULT_FROM_WIN32(GetLastError()));
}
我认为修复它超出了我的能力范围,因为上面的代码在 MFC 中。使用 Visual Studio 2013 编译时,相同的代码运行良好。请参阅堆栈的附图,显示我调用时引发的异常(并在内部捕获)
accelerator_view acc_view = accelerator().default_view;
问题:如何在退出之前清理 AMP 并在调用 GetExitCodeProcess() 时获得正确的结果?
下图:
解决方案
解决了!如果你添加
concurrency::amp_uninitialize();
使用AMP框架后,调用者进程调用时
::GetExitCodeProcess(hChildProcess, &retVal);
retVal
参数填写正确。
推荐阅读
- php - 使用相似对象对数组或 laravel 集合进行分组并添加计数
- cucumber - Cucumber Scenario 大纲最佳实践
- python - Pandas ValueError:无法设置没有定义索引的框架和无法转换为系列的值
- java - Android Studio 闹钟 MP3 歌曲
- java - 使用 java 流从一个非常嵌套的数组创建一个 Map
- amazon-web-services - 第三方工具 ecs-deploy 在部署时出错
- pytorch - 如何在 Pytorch 中使用 Tensorboard 只需画一个简单的网络
- java - Java 错误:“线程“主”java.util.InputMismatchException 中的异常”
- jquery - 当我们添加删除旧 eval 值并在 JQuery 中替换新按钮值的新方程时,如何在 JQuery 中制作计算器?
- c# - VB.net C# 数字和字母生成器