Repository: rocmsoftwareplatform/tensile
Issue:  '/opt/rocm/bin/hcc-config' path hardcoded in Tensile


When building tensile in a docker we have the below error:
`FileNotFoundError: [Errno 2] No such file or directory: '/opt/rocm/bin/hcc-config'`

In a docker this does not work since we are using a linked path not the system linked path.
Tensile can instead use the `/opt/rocm/hcc/bin/hcc-config` path where is where the actual binary is installed.

```
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/cget/build/tmp-30667e2aac3647f982bfccb12d2861d4/build/virtualenv/bin/TensileCreateLibrary", line 10, in <module>
    sys.exit(TensileCreateLibrary())
  File "/usr/local/cget/build/tmp-30667e2aac3647f982bfccb12d2861d4/build/virtualenv/lib/python3.5/site-packages/Tensile/TensileCreateLibrary.py", line 993, in TensileCreateLibrary
    kernelWriterSource, kernelWriterAssembly)
  File "/usr/local/cget/build/tmp-30667e2aac3647f982bfccb12d2861d4/build/virtualenv/lib/python3.5/site-packages/Tensile/TensileCreateLibrary.py", line 299, in writeSolutionsAndKernels
    codeObjectFiles += buildSourceCodeObjectFiles(kernelFiles, kernels + kernelsBetaOnly, outputPath)
  File "/usr/local/cget/build/tmp-30667e2aac3647f982bfccb12d2861d4/build/virtualenv/lib/python3.5/site-packages/Tensile/TensileCreateLibrary.py", line 138, in buildSourceCodeObjectFiles
    method=lambda x: x.starmap)
  File "/usr/local/cget/build/tmp-30667e2aac3647f982bfccb12d2861d4/build/virtualenv/lib/python3.5/site-packages/Tensile/Common.py", line 1133, in ParallelMap
    rv = mapFunc(function, objects)
  File "/usr/lib/python3.5/multiprocessing/pool.py", line 268, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
  File "/usr/lib/python3.5/multiprocessing/pool.py", line 608, in get
    raise self._value

FileNotFoundError: [Errno 2] No such file or directory: '/opt/rocm/bin/hcc-config'

CMake Error at /usr/local/cget/build/tmp-30667e2aac3647f982bfccb12d2861d4/build/virtualenv/cmake/TensileConfig.cmake:87 (message):
  Error generating kernels
Call Stack (most recent call first):
  library/src/CMakeLists.txt:41 (TensileCreateLibrary)
```

Changed files:
Tensile/TensileCreateLibrary.py

diff --git a/Tensile/TensileCreateLibrary.py b/Tensile/TensileCreateLibrary.py
index 1651f96f..3c0f4eb7 100644
--- a/Tensile/TensileCreateLibrary.py
+++ b/Tensile/TensileCreateLibrary.py
@@ -95,6 +95,16 @@ def getAssemblyCodeObjectFiles(kernels, kernelsBetaOnly, kernelWriterSource, ker
 
         return newCOFiles
 
+def which(p):
+    exes = [p+x for x in ['', '.exe', '.bat']]
+    system_path = os.environ['PATH'].split(os.pathsep)
+    for dirname in system_path+['/opt/rocm/bin']:
+        for exe in exes:
+            candidate = os.path.join(os.path.expanduser(dirname), exe)
+            if os.path.isfile(candidate):
+                return candidate
+    return None
+
 
 def buildSourceCodeObjectFile(outputPath, kernelFile):
     buildPath = ensurePath(os.path.join(globalParameters['WorkingPath'], 'code_object_tmp'))
@@ -109,12 +119,12 @@ def buildSourceCodeObjectFile(outputPath, kernelFile):
 
     archFlags = ['-amdgpu-target=gfx'+''.join(map(str,arch)) for arch in globalParameters['SupportedISA']]
 
-    hipFlags = subprocess.check_output(['/opt/rocm/bin/hcc-config', '--cxxflags', '--shared']).decode().split(' ')
-    hipLinkFlags = subprocess.check_output(['/opt/rocm/bin/hcc-config', '--ldflags', '--shared']).decode().split(' ')
+    hipFlags = subprocess.check_output([which('hcc-config'), '--cxxflags', '--shared']).decode().split(' ')
+    hipLinkFlags = subprocess.check_output([which('hcc-config'), '--ldflags', '--shared']).decode().split(' ')
 
     hipFlags += ['-I', outputPath]
 
-    compileArgs = ['/opt/rocm/bin/hcc'] + hipFlags + archFlags + [kernelFile, '-c', '-o', objectFilepath]
+    compileArgs = [which('hcc')] + hipFlags + archFlags + [kernelFile, '-c', '-o', objectFilepath]
     linkArgs = [globalParameters['AssemblerPath']] + hipLinkFlags + archFlags + [objectFilepath, '-shared', '-o', soFilepath]
     extractArgs = [globalParameters['ExtractKernelPath'], '-i', soFilename]