Skip to content

Commit ec7b77b

Browse files
committed
GPU CPUDevice: Add consistency check for some RTC parameters
1 parent 18a8b41 commit ec7b77b

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎GPU/GPUTracking/Base/cpudevice/GPUReconstructionCPUDevice.cxx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ GPUReconstructionCPUDevice::GPUReconstructionCPUDevice(const GPUSettingsDeviceBa
3939
{
4040
if (mMaster == nullptr) {
4141
mInternals = new GPUReconstructionCPUDeviceInternals;
42-
*mParDevice = *mParCPU; // We run the CPU kernels on the "device", so we use the CPU kernel parameters
43-
mParDevice->par_ALTERNATE_BORDER_SORT = 1; // Required by the GPU code path without RTC
44-
mParDevice->par_CF_SCAN_WORKGROUP_SIZE = 1; // No block-wide scan with 1 thread per block, the clusterizer uses the CPU stream compaction
42+
*mParDevice = *mParCPU; // We run the host-compiled CPU kernels on the "device", so the device parameters must be the CPU kernel parameters. Other values are possible only with RTC (genRTC), checked in InitDevice_Runtime
4543
for (auto& v : mParDevice->par_LB_maxThreads) {
4644
v = 1;
4745
}
@@ -72,6 +70,14 @@ int32_t GPUReconstructionCPUDevice::InitDevice_Runtime()
7270
exit(0);
7371
}
7472

73+
if (mProcessingSettings->alternateBorderSort == -1) {
74+
mProcessingSettings->alternateBorderSort = 1; // Required by the GPU code path without RTC
75+
}
76+
if (!GetProcessingSettings().rtc.enable && memcmp(&mParDevice->par_LB_forceBlocks + 1, &mParCPU->par_LB_forceBlocks + 1, (const char*)(mParCPU + 1) - (const char*)(&mParCPU->par_LB_forceBlocks + 1))) { // All members behind the launch bounds
77+
GPUError("CPUDevice kernel parameters differ from the parameters the host kernels were compiled with, this is possible only with RTC");
78+
return 1;
79+
}
80+
7581
if (mMaster == nullptr) {
7682
mMultiprocessorCount = std::max<int32_t>(1, mMaxHostThreads); // One device block runs as one TBB task
7783
mThreadCount = 1;

‎GPU/GPUTracking/Base/cpudevice/GPUReconstructionCPUDeviceGenRTC.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ int32_t GPUReconstructionCPUDevice::genRTC(std::string& filename, uint32_t& nCom
6060
const std::string baseCommand = rtc::baseCommand(proc, std::string_view(_binary_GPUReconstructionCPUDevicertc_command_start, _binary_GPUReconstructionCPUDevicertc_command_len)) + " " + proc.rtctech.overrideArchitecture;
6161
const std::string noFastMath(_binary_GPUReconstructionCPUDevicertc_command_no_fast_math_start, _binary_GPUReconstructionCPUDevicertc_command_no_fast_math_len);
6262

63+
mParDevice->par_CF_SCAN_WORKGROUP_SIZE = 1; // Must match the 1 thread per block for the scan kernels to compile, the clusterizer uses the CPU stream compaction
6364
rtc::loadLaunchBounds(proc, *mParDevice);
6465
const std::string launchBounds = rtc::launchBoundsCode(proc, *mParDevice, 0, mWarpSize);
6566
if (proc.rtctech.printLaunchBounds >= 2) {

0 commit comments

Comments
 (0)