Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate HIP backend to bldr infrastructure. #296

Open
wants to merge 1 commit into
base: code-reflection
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import hat.backend.c99codebuilders.C99HatKernelBuilder;
import hat.optools.OpWrapper;

import java.lang.reflect.code.Op;
import java.lang.reflect.code.type.JavaType;
import jdk.incubator.code.Op;
import jdk.incubator.code.type.JavaType;

public class HIPHatKernelBuilder extends C99HatKernelBuilder<HIPHatKernelBuilder> {

Expand Down
1 change: 1 addition & 0 deletions hat/backends/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ You should have received a copy of the GNU General Public License version
<module>cuda</module>
<module>mock</module>
<module>opencl</module>
<module>hip</module>
</modules>
<build>
<plugins>
Expand Down
13 changes: 10 additions & 3 deletions hat/bld
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ void main(String[] args) {
var hip = Capabilities.HIP.of();
var capabilities= Capabilities.of(opencl, opengl, cuda, hip);
var cmakeProbe = new CMakeProbe(buildDir, capabilities);
if (opencl.available()) {

if (opencl.available() && !hip.available()) {
System.out.println("OPENCL FOUND");
if (extractedOpenCLJar.exists()) {
println("We've already extracted and jarred" + extractedOpenCLJar.path());
} else {
Expand Down Expand Up @@ -116,7 +118,7 @@ void main(String[] args) {
println("According to cmake probe this platform does not have OpenCL");
}

if (opengl.available()) {
if (opengl.available() && !hip.available()) {
if (extractedOpenGLJar.exists()) {
println("We've already extracted and jarred" + extractedOpenGLJar.path());
} else {
Expand Down Expand Up @@ -150,6 +152,11 @@ void main(String[] args) {
println("According to cmake probe this platform does not have CUDA");
}

if (hip.available()) {
} else {
println("According to cmake probe this platform does not have HIP");
}

var hatOpts = JavaOpts.of()
.enable_preview()
.add_modules("jdk.incubator.code")
Expand All @@ -163,7 +170,7 @@ void main(String[] args) {

// Here we create all backend jars.
backendsDir
.subDirs(backendDir -> !backendDir.matches("^.*(spirv|hip|shared|target|.idea)$"))
.subDirs(backendDir -> !backendDir.matches("^.*(spirv|shared|target|.idea)$"))
.peek(backendDir->println("Building backend " + backendDir.fileName()))
.forEach(backendDir->
buildDir.jarFile("hat-backend-" + backendDir.fileName() + "-1.0.jar",$->$.verbose(verbose)
Expand Down
4 changes: 3 additions & 1 deletion hat/bldr/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ Bldr.Dir includeDir(){
}

public static class HIP extends CMakeCapability {
public static String hipDirKey = "CMAKE_HIP_DIR";
public static String hipDirNotFoundValue = "CMAKE_HIP_DIR-NOTFOUND";
public HIP() {
super("HIP");
}
Expand All @@ -96,7 +98,7 @@ public static HIP of(){
}
@Override
public boolean available() {
return false;
return cmakeProbe.hasKey(hipDirKey) && !cmakeProbe.value(hipDirKey).equals(hipDirNotFoundValue);
}
}
public static class CUDA extends CMakeCapability {
Expand Down
2 changes: 1 addition & 1 deletion hat/docs/hat-01-03-building-hat.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ${JAVA_HOME}/bin/java \
```

The `hatrun` script can also be used which simply needs the backend
name `opencl|java|cuda|ptx|mock` and the package name `mandel`
name `opencl|java|cuda|ptx|hip|mock` and the package name `mandel`

```bash
java @bldr/args hatrun opencl mandel
Expand Down
2 changes: 1 addition & 1 deletion hat/hatrun
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main(String[] args) {
usage:
java @bldr/args hatrun [headless] backend package args ...
[headless] : Optional passes -Dheadless=true to app
backend : opencl|cuda|spirv|ptx|mock
backend : opencl|cuda|spirv|ptx|hip|mock
package : the examples package (and dirname under hat/examples)

class name is assumed to be package.Main (i.e. mandel.main)
Expand Down