Skip to content

How to regenerate kernel db

Chris Erb edited this page Jun 5, 2024 · 1 revision

The db_sync test from the test/gtest directory can be used to regenerate the *.kdb files in addition to verifying their accuracy.

Steps for generating kdb files:

  1. KDB files must be generated on their target architecture. Eg gfx942.kdb must be generated on a MI300 machine.

  2. Load a docker image on the machine with the desired software environment.

  3. Clone MIOpen and change to the desired branch. Also use git-lfs to pull the kdb files

    a. git-lfs pull --exclude=

  4. Install MIOpen dependencies if they are not already available on the image.

    a. cd MIOpen; CXX=/opt/rocm/llvm/bin/clang++ cget install -f ./dev-requirements.txt --prefix ~/MIOpen/deps

  5. Build MIOpen with COMGR and HIPRTC disabled so that kernel objects are generated without target id.

    a. mkdir build; cd build; CXX=/opt/rocm/llvm/bin/clang++ cmake -DMIOPEN_TEST_DBSYNC=1 -DCMAKE_INSTALL_PREFIX=~/MIOpen/install -DCMAKE_PREFIX_PATH=\~/MIOpen/deps -DMIOPEN_USE_COMGR=Off -DMIOPEN_USE_HIPRTC=Off ..

    b. LLVM_PATH=/opt/rocm/llvm make -j$(nproc) install test_db_sync

  6. Current copies of the MIOpen dbs will be in ~/MIOpen/build/share/miopen/db after building MIOpen. To do a full regeneration of the kdb, the target kdb will need to be emptied here.

    a. sqlite3 ~/MIOpen/build/share/miopen/db/gfx942.kdb "delete from kern_db"

  7. Now test_db_sync can be run to generate the full kdb in the user directory.

    a. MIOPEN_USER_DB_PATH=~/.cache/miopen MIOPEN_SYSTEM_DB_PATH=\~/MIOpen/build/share/miopen/db MIOPEN_TEST_DBSYNC=1 ./bin/test_db_sync

  8. The complete *.ukdb file will be at MIOPEN_USER_DB_PATH, copy this file to the target kdb name eg gfx942.kdb.

  9. Disable journaling for the new kdb file

    a. sqlite3 gfx942.kdb "pragma journal_mode=delete"

  10. Replace the kdb.bz2 file in MIOpen/src/kernels/

    a. lbzip2 -kf gfx942.kdb

  11. The .gitattributes file marks this filetype as a lfs file. git add/commit/push can be called on the kdb.bz2 file the same as a usual git file.