I use my C++ program to imitate James’s Rust program, in which I can easily change to different methods of memory allocation (Memory management — HIP 7.1.0 Documentation). James is using hipMalloc(), which allocates memory in the device (probably it falls back to one of the host ones). This hipMalloc() is not safe when we directly write into device memory from the host; instead, if it is used, we should use a copy operation to copy a vector allocated in host memory space. But, using hipMallocManaged() or hipHostMalloc() eliminates the non-recoverable crash during the allocation. So, I used hipMallocManaged() and never had a non-recoverable crash again.
I used rocgdb to debug the program. With 50000 matrix sizes, like James, I also get sometimes gpu reset, sometimes not.
I also tried to employ recommendations from HIP Debugging — HIP 6.0.0 Documentation , in particular, I use HIP_LAUNCH_BLOCKING=1 to serialize kernel enqueue. It somehow helped, but not always. So I can’t say the reset is because of a parallel kernel issue.
But one thing I noticed is that something happens either at the calling of rocblas_cgemm or after at hipDeviceSynchronize function. Unfortunately, I was not able to step into rocblas_cgemm() with rocgdb to check the point where the reset occurs. At least, currently, I don’t know how to do it.
I would say that memory allocations were always without the problem.
A successful 50k multiplication within rocgdb:
$ printenv | grep -i block
$ rocgdb --args ./matmulblas 50000
GNU gdb (GDB) 18.0.50.20250927-git
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./matmulblas...
(gdb) r
Starting program: /home/xyz/test/amdgpu_test/matmulblas 50000
warning: os_agent_id 16142 (`Device 1002:15bf.dd'): architecture gfx1103 not supported.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
matrix rows: 50000 cols: 50000 size: 2500000000 ram: 20000 MB
[New Thread 0x7fffeefff6c0 (LWP 73660)]
[New Thread 0x7fffee7fe6c0 (LWP 73661)]
[Thread 0x7fffee7fe6c0 (LWP 73661) exited]
Matrix A (input):
(2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i)
00 00 00 40 00 00 00 00
Matrix B (input):
(2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i) (2 + 0i)
00 00 00 40 00 00 00 00
Matrix C (input):
(0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i) (0 + 0i)
[New Thread 0x7fffed3ff6c0 (LWP 73820)]
❌️ Error while mapping shared library sections:
'memory://73646#offset=0x555555f22b00&size=47528': AMDGCN architecture 0x44 is not supported.
[New Thread 0x7fffe79ff6c0 (LWP 73821)]
[Thread 0x7fffe79ff6c0 (LWP 73821) exited]
❌️ Error while mapping shared library sections:
'memory://73646#offset=0x555555cfdc60&size=261704': AMDGCN architecture 0x44 is not supported.
❌️ Error while mapping shared library sections:
'memory://73646#offset=0x55555605c0a0&size=55992': AMDGCN architecture 0x44 is not supported.
Matrix C (output):
(200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i) (200000 + 0i)
calc1: 8972 us
sync: 1863986983 us
[Thread 0x7fffed3ff6c0 (LWP 73820) exited]
[Thread 0x7fffeefff6c0 (LWP 73660) exited]
[Inferior 1 (process 73646) exited normally]
Look at the warning and errors (not affecting the program run).