Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 92fe21b

Browse files
author
Sven Verdoolaege
committed
use isl::ast_build::set_at_each_domain
1 parent 40b9224 commit 92fe21b

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

src/core/polyhedral/codegen_cuda.cc

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,9 @@ string emitCudaKernel(
739739
emitTensorViews(ss, scop.halide.inputs, paramValues);
740740
emitTmpDecl(ss, scop);
741741
emitPromotedArrayViewsHalide(ss, scop);
742-
// TODO: improve support for C++ callbacks in isl bindings generator
743-
// see https://github.com/PollyLabs/isl/issues/24
744-
// This cannot be done via islpp_wrap because the callback is stored for
745-
// later use while islpp_wrap passes a pointer to a stack-allocated
746-
// object to the call as a means to support capturing lambdas.
747-
auto collect =
748-
[](isl_ast_node* n, isl_ast_build* b, void* u) -> isl_ast_node* {
742+
IteratorMapsType iteratorMaps;
743+
auto collect = [&iteratorMaps](
744+
isl::ast_node n, isl::ast_build b) -> isl::ast_node {
749745
auto collectIteratorMaps =
750746
[](isl::ast_node node,
751747
isl::ast_build build,
@@ -776,9 +772,7 @@ string emitCudaKernel(
776772
return node.set_annotation(nodeId);
777773
};
778774

779-
auto uv = static_cast<IteratorMapsType*>(u);
780-
return collectIteratorMaps(isl::manage(n), isl::manage_copy(b), uv)
781-
.release();
775+
return collectIteratorMaps(n, b, &iteratorMaps);
782776
};
783777

784778
auto bands = detail::ScheduleTree::collect(
@@ -796,10 +790,8 @@ string emitCudaKernel(
796790
checkValidIslSchedule(mscop.schedule());
797791
auto schedule = detail::toIslSchedule(mscop.schedule());
798792
auto ctx = schedule.get_ctx();
799-
IteratorMapsType iteratorMaps;
800793
auto astBuild = isl::ast_build(schedule.get_ctx());
801-
astBuild = isl::manage(isl_ast_build_set_at_each_domain(
802-
astBuild.release(), collect, &iteratorMaps));
794+
astBuild = astBuild.set_at_each_domain(collect);
803795
astBuild = astBuild.set_iterators(Codegen::makeLoopIterators(ctx, maxDepth));
804796
auto astNode = astBuild.node_from(schedule);
805797
AstPrinter(CodegenContext(ss, mscop, iteratorMaps)).emit(astNode);

src/core/polyhedral/codegen_llvm.cc

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -689,13 +689,10 @@ struct IslCodegenRes {
689689
};
690690

691691
IslCodegenRes codegenISL(const Scop& scop) {
692-
// TODO: improve support for C++ callbacks in isl bindings generator
693-
// see https://github.com/PollyLabs/isl/issues/24
694-
// This cannot be done via islpp_wrap because the callback is stored for
695-
// later use while islpp_wrap passes a pointer to a stack-allocated
696-
// object to the call as a means to support capturing lambdas.
697-
auto collect =
698-
[](isl_ast_node* n, isl_ast_build* b, void* uTuple) -> isl_ast_node* {
692+
IteratorMapsType iteratorMaps;
693+
StmtSubscriptExprMapType stmtSubscripts;
694+
auto collect = [&iteratorMaps, &scop, &stmtSubscripts](
695+
isl::ast_node n, isl::ast_build b) -> isl::ast_node {
699696
auto collectIteratorMaps =
700697
[](isl::ast_node node,
701698
isl::ast_build build,
@@ -738,16 +735,8 @@ IslCodegenRes codegenISL(const Scop& scop) {
738735
return node.set_annotation(stmtId);
739736
};
740737

741-
auto& t = *static_cast<
742-
std::tuple<IteratorMapsType&, Scop&, StmtSubscriptExprMapType&>*>(
743-
uTuple);
744-
745-
auto& uv = std::get<0>(t);
746-
auto& scop = std::get<1>(t);
747-
auto& stmtSubscripts = std::get<2>(t);
748-
return collectIteratorMaps(
749-
isl::manage(n), isl::manage_copy(b), uv, scop, stmtSubscripts)
750-
.release();
738+
auto& uv = iteratorMaps;
739+
return collectIteratorMaps(n, b, uv, scop, stmtSubscripts);
751740
};
752741

753742
auto bands = detail::ScheduleTree::collect(
@@ -765,12 +754,8 @@ IslCodegenRes codegenISL(const Scop& scop) {
765754
checkValidIslSchedule(scop.scheduleRoot());
766755
auto schedule = detail::toIslSchedule(scop.scheduleRoot());
767756
auto ctx = schedule.get_ctx();
768-
IteratorMapsType iteratorMaps;
769-
StmtSubscriptExprMapType stmtSubscripts;
770757
auto astBuild = isl::ast_build(schedule.get_ctx());
771-
auto t = std::tie(iteratorMaps, scop, stmtSubscripts);
772-
astBuild = isl::manage(
773-
isl_ast_build_set_at_each_domain(astBuild.release(), collect, &t));
758+
astBuild = astBuild.set_at_each_domain(collect);
774759
astBuild = astBuild.set_iterators(Codegen::makeLoopIterators(ctx, maxDepth));
775760
auto astNode = astBuild.node_from(schedule);
776761
return {

0 commit comments

Comments
 (0)