One compilation unit in Release, all others in Debug. MSVC

Viewed 49

The following code is not fast enough to run in real-time in a debug build, but is fast enough in a release build. So I though I'd just change the compilation options for just the cpp file it is in.

I tried the obvious /O2 and then /arch:AVX2 and then set all options under C++ > Optimization and C++ > Code Generation to be the same as the release build (excluding whole program optimization /GL).

But this didn't work so I'd like to know why.

Also, I've just run the debug build without the debugger so it's not that.

inline uint8_t float32_to_unorm8(float in)
{
    return std::clamp(in, 0.f, 1.f) * std::numeric_limits<uint8_t>::max();
}

std::array<uint8_t, 4> kernel(float in)
{
    return { float32_to_unorm8(in / 951.f), float32_to_unorm8(in / 951.f),
        in == 0.f ? uint8_t(0) : std::numeric_limits<uint8_t>::max(), std::numeric_limits<uint8_t>::max() };
}

void DtwAligner::copy_to_upload()
{
    auto index = upload_write_sentinel;
    auto dest_span = upload_cpus[index % NUM_UPLOADS];

    for (auto i : ranges::views::ints(0u, ACCUMULATE_LENGTH))
    {
        auto source_span = accumulate_rows[(i + accumulate_index) % ACCUMULATE_LENGTH];
        std::transform(source_span.begin(), source_span.end(), dest_span.data() + i * UploadStride, &kernel);
    }
    upload_write_sentinel += 1;
}
0 Answers
Related