Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active July 10, 2025 19:38
Show Gist options
  • Save Hermann-SW/8f82f3f16a8f6b93e7a222405933bec9 to your computer and use it in GitHub Desktop.
Save Hermann-SW/8f82f3f16a8f6b93e7a222405933bec9 to your computer and use it in GitHub Desktop.
OpenCL example notes
see comments
@Hermann-SW
Copy link
Author

Hermann-SW commented Jul 6, 2025

Not sure yet what the other GPU problems are (Vega56 is single GPU in its PC,
"Radeons" PC has ̶t̶w̶o̶ (now) single Vega64 and 7950x PC has three MI50s).

Found it — at least for Instinct MI50 GPUs.
I remembered that on the AMD 7950X CPU PC I had tried to disable internal graphics card in Bios, but was not successful before moving to basement. The internal "GPU-XX" seems to make the problems:

hermann@7950x:~$ !rocm
rocminfo | grep Uuid.*GPU
  Uuid:                    GPU-c49e19417337ece3               
  Uuid:                    GPU-f890794172e62691               
  Uuid:                    GPU-13c24061732c730c               
  Uuid:                    GPU-XX                             
hermann@7950x:~$ 

My AMD 7600X CPU PC has four Instinct MI50s, and internal graphics card disabled in Bios (no GPU-XX):

hermann@7600x:~$ rocminfo | grep Uuid
  Uuid:                    CPU-XX                             
  Uuid:                    GPU-d64a58a17330f0ed               
  Uuid:                    GPU-6e56508172dc76b6               
  Uuid:                    GPU-6a0e7961732c730d               
  Uuid:                    GPU-304c70e172dc768c               
hermann@7600x:~$ 

And here the blog hello world works (not he very first time, but two times after that):

hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ hipcc gpuHelloWorld.cpp -o gpuHelloWorld
hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ ./gpuHelloWorld 
hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ ./gpuHelloWorld 
Hello world from block 1 and thread 4 
Hello world from block 1 and thread 5 
Hello world from block 1 and thread 6 
Hello world from block 1 and thread 7 
Hello world from block 2 and thread 8 
Hello world from block 2 and thread 9 
Hello world from block 2 and thread 10 
Hello world from block 2 and thread 11 
Hello world from block 3 and thread 12 
Hello world from block 3 and thread 13 
Hello world from block 3 and thread 14 
Hello world from block 3 and thread 15 
Hello world from block 0 and thread 0 
Hello world from block 0 and thread 1 
Hello world from block 0 and thread 2 
Hello world from block 0 and thread 3 
hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ ./gpuHelloWorld 
Hello world from block 0 and thread 0 
Hello world from block 0 and thread 1 
Hello world from block 0 and thread 2 
Hello world from block 0 and thread 3 
Hello world from block 3 and thread 12 
Hello world from block 3 and thread 13 
Hello world from block 3 and thread 14 
Hello world from block 3 and thread 15 
Hello world from block 1 and thread 4 
Hello world from block 1 and thread 5 
Hello world from block 1 and thread 6 
Hello world from block 1 and thread 7 
Hello world from block 2 and thread 8 
Hello world from block 2 and thread 9 
Hello world from block 2 and thread 10 
Hello world from block 2 and thread 11 
hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ 

So the most important to me Instinct MI50 GPUs now work (I will have to correctly disable internal graphics card on "7950x" PC).
That is no problem because both PCs (with 1850W PSU each) are operated headless in basement:
50pc

Next I tried the rocm-examples repo hello world, and it works as well.
AND it showed the reason why the first time calling gpuHelloWorld above showed no output:
"no ROCm-capable device is detected"

hermann@7600x:~/rocm-examples$ cd HIP-Basic/hello_world
hermann@7600x:~/rocm-examples/HIP-Basic/hello_world$ make
/opt/rocm/bin/hipcc -std=c++17 -Wall -Wextra -I ../../Common  -o hip_hello_world main.hip 
hermann@7600x:~/rocm-examples/HIP-Basic/hello_world$ ./hip_hello_world 
Hello world from host!
Hello world from device or host!
An error encountered: "no ROCm-capable device is detected" at main.hip:77
hermann@7600x:~/rocm-examples/HIP-Basic/hello_world$ ./hip_hello_world 
Hello world from host!
Hello world from device or host!
Hello world from device or host!
Hello world from device or host!
Hello world from device or host!
Hello world from device or host!
Hello world from device kernel block 0 thread 0!
Hello world from device kernel block 0 thread 1!
Hello world from device kernel block 1 thread 0!
Hello world from device kernel block 1 thread 1!
hermann@7600x:~/rocm-examples/HIP-Basic/hello_world$ 

The rocm-examples repo hello world has this at the end of code:

$ tail -3 ../../HIP-Basic/hello_world/main.hip 
    // Wait on all active streams on the current device.
    HIP_CHECK(hipDeviceSynchronize());
}
$

I added this simple equivalent to blog hello world:

hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ tail -4 gpuHelloWorld.cpp
    assert(hipDeviceSynchronize() == hipSuccess);

    return 0;
}
hermann@7600x:~/rocm-examples/blog/gpuHelloWorld$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment