Repository: spack/spack

Issue:
Add AMD MIGraphX recipe for rocm 3.5



Discussion:
@bvanessen @srekolam @arjun-raj-kuppala @haampie can you review this?
@adamjstewart 
Need your inputs here. This errors out when i run 'spack install migraphx'
==> Error: Multiple providers found for 'pkgconfig': ['pkg-config@0.29.2%gcc@7.3.1+internal_glib arch=linux-centos7-zen', 'pkgconf@1.7.3%gcc@7.3.1 arch=linux-centos7-zen']

This goes through fine when i run 'spack install migraphx ^pkg-config'

What is the best solution for this kind of errors?
> What is the best solution for this kind of errors?

```console
$ spack clean -m
```
@adamjstewart , can you please let us know if there is any thing pending on our side ?
Can you resolve the merge conflict with `hip`?

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/half/package.py b/var/spack/repos/builtin/packages/half/package.py
--- a/var/spack/repos/builtin/packages/half/package.py
+++ b/var/spack/repos/builtin/packages/half/package.py
@@ -22,8 +22,8 @@ class Half(Package):
     maintainers = ['bvanessen']
 
     version('2.1.0', sha256='ad1788afe0300fa2b02b0d1df128d857f021f92ccf7c8bddd07812685fa07a25')
-
-    patch('f16fix.patch')
+    version('1.12.0', sha256='cdd70d3bf3fe091b688e7ab3f48471c881a197d2c186c95cca8bf156961fb41c')
+    patch('f16fix.patch', when='@2.1.0')
 
     def install(self, spec, prefix):
         mkdirp(prefix.include)
diff --git a/var/spack/repos/builtin/packages/hip/package.py b/var/spack/repos/builtin/packages/hip/package.py
--- a/var/spack/repos/builtin/packages/hip/package.py
+++ b/var/spack/repos/builtin/packages/hip/package.py
@@ -29,9 +29,9 @@ class Hip(CMakePackage):
         depends_on('hip-rocclr@' + ver,  type='build', when='@' + ver)
         depends_on('hsakmt-roct@' + ver, type='build', when='@' + ver)
         depends_on('hsa-rocr-dev@' + ver, type='link', when='@' + ver)
-        depends_on('comgr@' + ver, when='@' + ver)
+        depends_on('comgr@' + ver, type=('build', 'link', 'run'), when='@' + ver)
         depends_on('llvm-amdgpu@' + ver, type='build', when='@' + ver)
-        depends_on('rocm-device-libs@' + ver, type='build', when='@' + ver)
+        depends_on('rocm-device-libs@' + ver, type=('build', 'link', 'run'), when='@' + ver)
         depends_on('rocminfo@' + ver, type='build', when='@' + ver)
 
     # Notice: most likely this will only be a hard dependency on 3.7.0
diff --git a/var/spack/repos/builtin/packages/migraphx/package.py b/var/spack/repos/builtin/packages/migraphx/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin/packages/migraphx/package.py
@@ -0,0 +1,49 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class Migraphx(CMakePackage):
+    """ AMD's graph optimization engine."""
+
+    homepage = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX"
+    url = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/archive/rocm-3.5.0.tar.gz"
+
+    maintainers = ['srekolam', 'arjun-raj-kuppala']
+
+    def url_for_version(self, version):
+        url = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/archive/{0}.tar.gz"
+        if version > Version('3.5'):
+            return url.format(version)
+        else:
+            return url.format('rocm-' + version)
+
+    version('3.8.0', sha256='08fa991349a2b95364b0a69be7960580c3e3fde2fda0f0c67bc41429ea2d67a0')
+    version('3.7.0', sha256='697c3c7babaa025eaabec630dbd8a87d10dc4fe35fafa3b0d3463aaf1fc46399')
+    version('3.5.0', sha256='5766f3b262468c500be5051a056811a8edfa741734a5c08c4ecb0337b7906377')
+
+    variant('build_type', default='Release', values=("Release", "Debug"), description='CMake build type')
+
+    depends_on('cmake@3:', type='build')
+    depends_on('protobuf', type='link')
+    depends_on('blaze', type='build')
+    depends_on('nlohmann-json', type='link')
+    depends_on('py-pybind11', type='build')
+    depends_on('msgpack-c', type='link')
+    depends_on('half@1.12.0', type='link')
+    for ver in ['3.5.0', '3.7.0', '3.8.0']:
+        depends_on('hip@' + ver, type='build', when='@' + ver)
+        depends_on('rocm-cmake@' + ver, type='build', when='@' + ver)
+        depends_on('llvm-amdgpu@' + ver, type='build', when='@' + ver)
+        depends_on('rocblas@' + ver, type='link', when='@' + ver)
+        depends_on('miopen-hip@' + ver, type='link', when='@' + ver)
+
+    def cmake_args(self):
+        args = [
+            '-DCMAKE_CXX_COMPILER={0}/bin/clang++'
+            .format(self.spec['llvm-amdgpu'].prefix)
+        ]
+        return args


Test patch: