Skip to content

Commit

Permalink
Use Op.ofQuoted
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Sandoz committed Jan 17, 2025
1 parent 82e0e55 commit ee3da03
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hat/docs/hat-05-accelerator-compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Here is how we extract the 'target' from such a lambda

```java
public void compute(QuotableComputeContextConsumer qccc) {
Quoted quoted = qccc.quoted();
Quoted quoted = Op.ofQuotable(qccc).orElseThrow();
LambdaOpWrapper lambda = OpTools.wrap((CoreOps.LambdaOp)quoted.op());

Method method = lambda.getQuotableComputeContextTargetMethod();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void test() {
}

static void isMethodRef(Quotable q) {
Quoted quoted = q.quoted();
Quoted quoted = Op.ofQuotable(q).orElseThrow();;
CoreOp.LambdaOp op = (CoreOp.LambdaOp) quoted.op();
System.out.println(isMethodRef(op));
}
Expand Down
4 changes: 3 additions & 1 deletion hat/hat/src/main/java/hat/Accelerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;

import jdk.incubator.code.Op;
import jdk.incubator.code.Quotable;
import jdk.incubator.code.Quoted;
import jdk.incubator.code.op.CoreOp;
Expand Down Expand Up @@ -147,7 +149,7 @@ public interface QuotableComputeContextConsumer extends Quotable, Consumer<Compu
*/

public void compute(QuotableComputeContextConsumer quotableComputeContextConsumer) {
Quoted quoted = quotableComputeContextConsumer.quoted();
Quoted quoted = Op.ofQuotable(quotableComputeContextConsumer).orElseThrow();
LambdaOpWrapper lambda = OpWrapper.wrap((CoreOp.LambdaOp) quoted.op());
Method method = lambda.getQuotableTargetMethod(this.lookup);

Expand Down
2 changes: 1 addition & 1 deletion hat/hat/src/main/java/hat/ComputeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected ComputeContext(Accelerator accelerator, Method computeMethod) {
*/

public void dispatchKernel(int range, QuotableKernelContextConsumer quotableKernelContextConsumer) {
Quoted quoted = quotableKernelContextConsumer.quoted();
Quoted quoted = Op.ofQuotable(quotableKernelContextConsumer).orElseThrow();
LambdaOpWrapper lambdaOpWrapper = OpWrapper.wrap((CoreOp.LambdaOp) quoted.op());
MethodRef methodRef = lambdaOpWrapper.getQuotableTargetMethodRef();
KernelCallGraph kernelCallGraph = computeCallGraph.kernelCallGraphMap.get(methodRef);
Expand Down

0 comments on commit ee3da03

Please sign in to comment.