Regression in 26.9 -- abort after GPU kernel-launch, when built for both gpu and multicore

nvc 26.9 (-acc=gpu,multicore): “Rebuild this file” abort after GPU launch

Summary

Built with -acc=gpu,multicore (or -acc=gpu,host) at -O1 and above, the program below runs its compute region on the GPU and then aborts:

Current file:     dead-loop-dispatch.c
        function: fill
        line:     27
This file was compiled: -acc=gpu -gpu=cc100
Rebuild this file with -gpu=cc100 to use NVIDIA Tesla GPU 0

The kernel has run by then. In the host code, the GPU branch’s __pgi_uacc_computedone and its jump past the other targets’ versions are gone. The launch therefore falls through into the multicore test, which fails on a GPU and leads to __pgi_uacc_noversion. The defect is already in nvcpfe’s output, before opt:

fill(), nvcpfe's LLVM IR (runtime calls and branches)
nvc 25.11   computestart2 launch computedone  br label %L.B0035  ; exit
nvc 26.9    computestart2 launch              br label %L.B0042  ; multicore test

Reproducer

dead-loop-dispatch.c (attached; main() checks the result). The region:

#pragma acc parallel loop copyout(y[0:n])
	for (int i = 0; i < n; ++i) {
		/* 1 in the GPU's code, 0 in the host's. */
		int onDev = acc_on_device(acc_device_not_host);

		if (0)
			for (int j = 0; j < 2; ++j)
				y[i] = i + j;
		y[i] = onDev ? i : -1;
	}

$ nvc -acc=gpu,multicore -O2 dead-loop-dispatch.c && ./a.out

nvc    options                                  fill() after the launch    run
26.9   -acc=gpu,multicore -O2, cuda12.9         noversion                  abort
26.9   -acc=gpu,multicore -O2, cuda13.3         noversion                  abort
26.9   -acc=gpu,host -O2                        noversion                  abort
26.9   -acc=gpu -O2                             computedone                ok
26.9   -acc=gpu,multicore -O0                   computedone                ok
25.11  -acc=gpu,multicore -O2, cuda12.9/13.0    computedone                ok

-O1, -O3 and -fast emit the same launch, noversion sequence as -O2; these were checked in the object code only. nvc++ behaves the same.

The trigger needs both of these:

  • a value that differs between the targets: acc_on_device() here, and __builtin_is_device_code() does the same;
  • a loop in code that is dead at compile time.

With WIDE 1, with the dead loop replaced by a single statement, or with onDev replaced by a constant, the code is right. In C++, a template parameter makes the same dead code: if (W) with W false fails the same way, and if constexpr (W) does not.

Impact

Our production kernel is a function template holding one compute region, built -acc=gpu,multicore so that the same code also runs on multicore CPUs. It picks its lane stride with acc_on_device(). Built with 26.9, the instances whose bool template parameter leaves a loop dead abort on the GPU as above, and the other instances run. With 25.11 all of them run.

Expected

After the GPU launch the host continues past the region, as with 25.11.

Seen with nvc and nvc++ 26.9-0 (x86-64 host, B200 / cc100; also with -gpu=cc90 in the object code). 25.11-0 is right.

Hi UnitedMarsupials and thanks for the report.

I was able to reproduce the issue and filed TPR #39162. We’ll have engineering take a look.

Note that I moved your post from the CUDA forums to the NVHPC forum since I don’t monitor the CUDA forum.

-Mat