{"id":376,"date":"2022-09-11T10:04:27","date_gmt":"2022-09-11T10:04:27","guid":{"rendered":"https:\/\/blogs.gentoo.org\/gsoc\/?p=376"},"modified":"2022-09-11T10:04:27","modified_gmt":"2022-09-11T10:04:27","slug":"week-8-report-for-refining-rocm-packages-in-gentoo","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/gsoc\/2022\/09\/11\/week-8-report-for-refining-rocm-packages-in-gentoo\/","title":{"rendered":"Week 8 Report for Refining ROCm Packages in Gentoo"},"content":{"rendered":"<p>This week there are two major progress: <code>dev-util\/rocprofiler<\/code> and rocm.eclass.<\/p>\n<p>I have implemented all the functions I think necessary for rocm.eclass. It was just send to rocm.eclass draft to gentoo-dev mailing list (also with a Github PR at [1]), please have a review. In the following weeks, I will collect feedbacks and continue to polish it.<\/p>\n<p>In summary, I have implemented those functions which is listed in my proposal:<br \/>\n&#8211; <code>USE_EXPNAD<\/code> of amdgpu_targets_, and ROCM_USEDEP to make the use flag coherent among dependencies;<br \/>\n&#8211; <code>rocm_src_configure<\/code> contains common arguments in <code>src_prepare<\/code>;<br \/>\n&#8211; <code>rocm_src_test<\/code> which checks the permission on <code>\/dev\/kfd<\/code> and <code>\/dev\/dri\/render*<\/code><\/p>\n<p>There are also something listed in proposal but I decided not to implement now:<br \/>\n&#8211; <code>rocm_src_prepare<\/code>: although there are some similarities among ebuilds, src_prepare are highly customized to each ROCm components. Unifying would take extra work.<br \/>\n&#8211; <code>SRC_URI<\/code>: currently all SRC_URI is already specified in each ebuilds. It does not hurt to keep the status quo.<\/p>\n<p>Moreover, during implementation I found another feature necessary<br \/>\n&#8211; <code>rocm_src_test<\/code>: correctly handles different scenarios. ROCm packages may have cmake test, which can be run using <code>cmake_src_test<\/code>, or only compiled some testing binaries which requires execution from command-line. I made <code>rocm_src_test<\/code> automatically detect the method, so ROCm packages just have to call this function directly without doing anything.<\/p>\n<p>Actually I have never imagined <code>rocm.eclass<\/code> could be in this shape eventually. Initially I just thought it would provide some utilities, mainly <code>src_test<\/code> and <code>USE_EXPAND<\/code>. But when implementing I found all these feature requires careful treatment. The comments (mainly examples) also takes half of the length. It ends up in 278 lines, which is a middle-sized among current eclasses. Maybe it can be further trimmed down after polishing, because there could be awkward implementations or re-inventions in it.<\/p>\n<p>Based on my draft <code>rocm.eclass<\/code>, I have prepared sci-libs\/roc*=5.1.3, sci-lib\/hip-*-5.1.3 and <code>dev-python\/cupy<\/code> making use of it. It feels great to simplify the ebuilds, and portage can handles the USE_EXPAND and dependencies just as expected. Once the <code>rocm.eclass<\/code> get in tree, I&#8217;ll push those ROCm-5.1.3 ebuilds.<\/p>\n<p>Anther thing to mention is that ROCm-5.1.3 toolchains finally get merged [5], with the fixed <code>dev-util\/rocprofiler-{4.3.0,5.0.2,5.1.3}<\/code>. rocprofiler is actually buggy before, because I thought I committed the patch which stripped the libhsa-amd-aqlprofile.so loading (I even claimed it in the commit message), but it was not committed and lost in history. So I reproduced the patch. Also, I did some research about this proprietary lib. By default, not loading it means tracing hsa\/hip is not possible &#8212; you only get basic information like name and time of each GPU kernel execution, but do not know the pipeline of kernel execution (which one has spawned which kernel). AQL should be HSA architected queuing language (HSA AQL), where https:\/\/llvm.org\/docs\/AMDGPUUsage.html#hsa-aql-queue documented. It did sound related to the pipeline of kernel dispatching. By the description, libhsa-amd-aqlprofile.so is an extension API of AQL Profile. But actually, patching the source code to let rocprofiler not loading libhsa-amd-aqlprofile.so does not breaks the tracing of hsa\/hip. So, I&#8217;m not sure why libhsa-amd-aqlprofile.so is needed, and raised a question at [2]. So I complete the fix in [3,4].<\/p>\n<p>According to the renewed proposal (I have been leaving for two weeks, so there are changes in plan), I should collect feedback and refine <code>rocm.eclass<\/code>, and prepare <code>dev-python\/cupy<\/code> and sci-libs\/rocWMMA. I&#8217;ll investigate ROCgdb, too. Also, rocm-device-libs is a major package because many users relies on it to provide opencl. I&#8217;ll work on bumping its version, too. What&#8217;s more, with hip-5.1.3 against vanilla clang, rocm for blender can land in ::gentoo.<\/p>\n<p>[1] https:\/\/github.com\/gentoo\/gentoo\/pull\/26784<br \/>\n[2] https:\/\/github.com\/RadeonOpenCompute\/ROCm\/issues\/1781<br \/>\n[3] https:\/\/github.com\/gentoo\/gentoo\/pull\/26755<br \/>\n[4] https:\/\/github.com\/gentoo\/gentoo\/pull\/26771<br \/>\n[5] https:\/\/github.com\/gentoo\/gentoo\/pull\/26441<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week there are two major progress: dev-util\/rocprofiler and rocm.eclass. I have implemented all the functions I think necessary for rocm.eclass. It was just send to rocm.eclass draft to gentoo-dev mailing list (also with a Github PR at [1]), please &hellip; <a href=\"https:\/\/blogs.gentoo.org\/gsoc\/2022\/09\/11\/week-8-report-for-refining-rocm-packages-in-gentoo\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":179,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/376"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/users\/179"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/comments?post=376"}],"version-history":[{"count":3,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/376\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/376\/revisions\/379"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/media?parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/categories?post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/tags?post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}