/* This testcase is part of GDB, the GNU debugger.
Copyright 2025-2026 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include
__device__ int global = 0;
__global__ void
kern ()
{
}
int __attribute__ ((optnone))
main (int argc, char* argv[])
{
kern<<<1, 1>>> ();
if (hipDeviceSynchronize () != hipSuccess)
return 1;
int *devGlobal;
if (hipGetSymbolAddress (reinterpret_cast (&devGlobal), global))
return 2;
/* Now update the device global from a CPU thread. Use a volatile
pointer at the access site so the store survives optimization
without forcing devGlobal itself to be volatile (which would
require dropping the qualifier with a C-style cast above). */
*static_cast (devGlobal) = 8;
return 0;
}