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

Commit ba396af

Browse files
Merge pull request #177 from facebookresearch/pr/persistent
use isl::ast_build::set_at_each_domain
2 parents 17b4322 + 92fe21b commit ba396af

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

src/core/polyhedral/codegen_cuda.cc

+5-13
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

+7-22
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,10 @@ struct IslCodegenRes {
650650
};
651651

652652
IslCodegenRes codegenISL(const Scop& scop) {
653-
// TODO: improve support for C++ callbacks in isl bindings generator
654-
// see https://github.com/PollyLabs/isl/issues/24
655-
// This cannot be done via islpp_wrap because the callback is stored for
656-
// later use while islpp_wrap passes a pointer to a stack-allocated
657-
// object to the call as a means to support capturing lambdas.
658-
auto collect =
659-
[](isl_ast_node* n, isl_ast_build* b, void* uTuple) -> isl_ast_node* {
653+
IteratorMapsType iteratorMaps;
654+
StmtSubscriptExprMapType stmtSubscripts;
655+
auto collect = [&iteratorMaps, &scop, &stmtSubscripts](
656+
isl::ast_node n, isl::ast_build b) -> isl::ast_node {
660657
auto collectIteratorMaps =
661658
[](isl::ast_node node,
662659
isl::ast_build build,
@@ -693,16 +690,8 @@ IslCodegenRes codegenISL(const Scop& scop) {
693690
return node.set_annotation(stmtId);
694691
};
695692

696-
auto& t = *static_cast<
697-
std::tuple<IteratorMapsType&, Scop&, StmtSubscriptExprMapType&>*>(
698-
uTuple);
699-
700-
auto& uv = std::get<0>(t);
701-
auto& scop = std::get<1>(t);
702-
auto& stmtSubscripts = std::get<2>(t);
703-
return collectIteratorMaps(
704-
isl::manage(n), isl::manage_copy(b), uv, scop, stmtSubscripts)
705-
.release();
693+
auto& uv = iteratorMaps;
694+
return collectIteratorMaps(n, b, uv, scop, stmtSubscripts);
706695
};
707696

708697
auto bands = detail::ScheduleTree::collect(
@@ -720,12 +709,8 @@ IslCodegenRes codegenISL(const Scop& scop) {
720709
checkValidIslSchedule(scop.scheduleRoot());
721710
auto schedule = detail::toIslSchedule(scop.scheduleRoot());
722711
auto ctx = schedule.get_ctx();
723-
IteratorMapsType iteratorMaps;
724-
StmtSubscriptExprMapType stmtSubscripts;
725712
auto astBuild = isl::ast_build(schedule.get_ctx());
726-
auto t = std::tie(iteratorMaps, scop, stmtSubscripts);
727-
astBuild = isl::manage(
728-
isl_ast_build_set_at_each_domain(astBuild.release(), collect, &t));
713+
astBuild = astBuild.set_at_each_domain(collect);
729714
astBuild = astBuild.set_iterators(Codegen::makeLoopIterators(ctx, maxDepth));
730715
auto astNode = astBuild.node_from(schedule);
731716
return {

third-party/islpp

Submodule islpp updated from ed0cae6 to 3e13c53

0 commit comments

Comments
 (0)