Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
07cdaf8
Synth scheduling implementation PR
amir734jj Apr 21, 2026
a6a637d
simplified the analysis
amir734jj Apr 21, 2026
07eb4a2
expose synth internals things to synth only
amir734jj Apr 21, 2026
67f5570
code improvements
amir734jj Apr 21, 2026
8351c28
just code improvement to avoid re-calculation of assignments
amir734jj Apr 21, 2026
ab3e1c0
basic code improvements
amir734jj Apr 21, 2026
c75b89d
fixed issue with codegen
amir734jj Apr 24, 2026
1e2d31c
Testing
amir734jj Apr 24, 2026
6f5421c
revert unnessary change
amir734jj Apr 24, 2026
2d6e165
smaller fixes
amir734jj May 12, 2026
02c406a
handle objects
amir734jj May 15, 2026
5003a86
Merge remote-tracking branch 'boyland/master' into user/amir734jj/syn…
amir734jj May 15, 2026
91cabc9
improved the Makefile
amir734jj May 15, 2026
ce5f91f
tiny change
amir734jj May 16, 2026
f4e13ea
Merge remote-tracking branch 'boyland/master' into user/amir734jj/syn…
amir734jj Jun 2, 2026
c83257a
Merge remote-tracking branch 'origin/master' into user/amir734jj/synt…
amir734jj Jun 16, 2026
cf786ee
Revert unnessary changes
amir734jj Jun 16, 2026
fc8695f
Merge remote-tracking branch 'origin/master' into user/amir734jj/synt…
amir734jj Jun 16, 2026
84a511e
add bigger outer fixed point loop
amir734jj Jun 16, 2026
f623302
more progress
amir734jj Jun 18, 2026
3d67e84
Merge remote-tracking branch 'origin/master' into user/amir734jj/synt…
amir734jj Jun 19, 2026
ed8f8e2
working
amir734jj Jun 20, 2026
43acc2e
added some TODOs
amir734jj Jun 21, 2026
beee561
WIP
amir734jj Jun 22, 2026
31d755b
Updated the code to allow local cycles
amir734jj Jun 29, 2026
bdf7e64
Merge remote-tracking branch 'boyland/master' into user/amir734jj/syn…
amir734jj Aug 2, 2026
cae11c2
synth run
amir734jj Aug 2, 2026
5bc4a1f
speed improvements
amir734jj Aug 3, 2026
0709d4d
Fix the build failing
amir734jj Aug 3, 2026
1c80055
top-level-match doesn't have an implicit node, build will pass now
amir734jj Aug 3, 2026
88192c7
Merge remote-tracking branch 'boyland/master' into user/amir734jj/syn…
amir734jj Aug 9, 2026
a1cdee7
unnessary change
amir734jj Aug 9, 2026
e541071
Simplify/refactor examples/scala/Makefile
amir734jj Aug 9, 2026
9a36a4f
Collect non-local dependencies of the field-assignment instances
amir734jj Aug 9, 2026
fc5fa45
increase pipeline stack size
amir734jj Aug 9, 2026
e05c81b
small fix up, revert
amir734jj Aug 10, 2026
d2aad1d
small optimization
amir734jj Aug 10, 2026
a7ee1e7
Update Makefile
amir734jj Aug 10, 2026
5237302
testing
amir734jj Aug 10, 2026
8f4b371
Update scc.c
amir734jj Aug 10, 2026
df7e9ee
wip
amir734jj Aug 10, 2026
9f28531
another try
amir734jj Aug 10, 2026
bf20927
Merge branch 'amir/patch-59' into user/amir734jj/synth-scheduling
amir734jj Aug 10, 2026
114584a
add a flag to turn off optimizations we added over Farrow
amir734jj Aug 12, 2026
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
5 changes: 4 additions & 1 deletion aps2scala/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CPP=g++
CPPFLAGS=-Wall -g -Wno-unused-variable -DUSING_CXX -DAPS2SCALA -I../parse -I../analyze -I../codegen -I../utilities

APS2SCALAOBJS = aps2scala.o dump-scala.o implement.o dyn-impl.o static-impl.o static-scc-impl.o
APS2SCALAOBJS = aps2scala.o dump-scala.o implement.o dyn-impl.o static-impl.o static-scc-impl.o synth-impl.o
APS2SCALALIBS = ../lib/aps-lib.o ../lib/aps-ag.a ../utilities/utilities.o
aps2scala : ${APS2SCALAOBJS} ${APS2SCALALIBS}
${CPP} ${CPPFLAGS} ${APS2SCALAOBJS} ${APS2SCALALIBS} -o aps2scala
Expand All @@ -11,6 +11,9 @@ ${APS2SCALAOBJS} : dump-scala.h
install: aps2scala
mv aps2scala ../bin/.

synth-impl.o : ../codegen/synth-impl.cc
${CPP} -c ${CPPFLAGS} $< -o $@

static-impl.o : ../codegen/static-impl.cc
${CPP} -c ${CPPFLAGS} $< -o $@

Expand Down
22 changes: 20 additions & 2 deletions aps2scala/aps2scala.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void usage() {
fprintf(stderr," -V increase verbosity of generation code\n");
fprintf(stderr," -G add Debug calls for every function\n");
fprintf(stderr," -C SCC chunk static scheduling\n");
fprintf(stderr," -F, --synth optimized SYNTH evaluation\n");
fprintf(stderr," -F0, --synth-original generate Farrow-style SYNTH evaluation\n");
fprintf(stderr," -p path set the APSPATH (overriding env. variable)\n");
exit(1);
}
Expand All @@ -40,6 +42,9 @@ extern int aps_yyparse(void);
Implementation* impl;
bool static_schedule = false;
bool is_tree_only_program = false;
bool synth_implementation = false;
// False runs related child cycles until values reaches fixed-point and always re-runs independent child cycles.
bool farrow_synth_improvements = true;

static void* program_is_tree_only(void *scope, void *node) {
if (ABSTRACT_APS_tnode_phylum(node) == KEYDeclaration) {
Expand Down Expand Up @@ -82,6 +87,15 @@ int main(int argc,char **argv) {
static_schedule = true;
static_scc_schedule = true;
continue;
} else if (streq(argv[i],"-F") || streq(argv[i],"--synth")) {
synth_implementation = true;
anc_analysis = true;
continue;
} else if (streq(argv[i],"-F0") || streq(argv[i],"--synth-original")) {
synth_implementation = true;
anc_analysis = true;
farrow_synth_improvements = false;
continue;
} else if (streq(argv[i],"-V") || streq(argv[i],"--verbose")) {
++verbose;
continue;
Expand Down Expand Up @@ -110,8 +124,12 @@ int main(int argc,char **argv) {
type_Program(p);
traverse_Program(program_is_tree_only, p, p);
aps_check_error("type");
if (static_schedule) {
impl = static_scc_schedule ? static_scc_impl : static_impl;
if (static_schedule || synth_implementation) {
if (static_schedule) {
impl = static_scc_schedule ? static_scc_impl : static_impl;
} else {
impl = synth_impl;
}
analyze_Program(p);
aps_check_error("analysis");
if (!impl) {
Expand Down
22 changes: 20 additions & 2 deletions aps2scala/dump-scala.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ void dump_scala_Declaration(Declaration decl,ostream& oss)
++nesting_level;

STATE *s = (STATE*)Declaration_info(decl)->analysis_state;
if (static_scc_schedule && s != NULL)
if ((static_scc_schedule || anc_analysis) && s != NULL)
{
activate_static_circular = s->loop_required;
}
Expand Down Expand Up @@ -2455,6 +2455,11 @@ void dump_Expression(Expression e, ostream& o)
dump_collect_Actuals(infer_expr_type(e),funcall_actuals(e),o);
return;
}

if (auto* synth = dynamic_cast<SynthImplementation*>(impl)) {
if (synth->try_dump_funcall(e, o)) return;
}

bool dump_anchor_actual = false;
if (should_include_ast_for_objects()) {
Expression fexpr = funcall_f(e);
Expand Down Expand Up @@ -2691,7 +2696,7 @@ string operator+(string s, int i)
string indent(int nl) { return string(indent_multiple*nl,' '); }

bool check_surrounding_decl(void* node, KEYTYPE_Declaration decl_key, Declaration* result_decl) {
while (node != NULL) {
while (node != NULL && ABSTRACT_APS_tnode_phylum(node) != KEY_ABSTRACT_APS_None) {
if (ABSTRACT_APS_tnode_phylum(node) == KEYDeclaration) {
Declaration decl = (Declaration)node;
if (Declaration_KEY(decl) == decl_key) {
Expand All @@ -2705,3 +2710,16 @@ bool check_surrounding_decl(void* node, KEYTYPE_Declaration decl_key, Declaratio
*result_decl = NULL;
return false;
}

bool check_surrounding_node(void* node, KEYTYPE_ABSTRACT_APS_Phylum ast_key, void** result_node) {
while (node != NULL && ABSTRACT_APS_tnode_phylum(node) != KEY_ABSTRACT_APS_None) {
if (ABSTRACT_APS_tnode_phylum(node) == ast_key) {
*result_node = node;
return true;
}
node = tnode_parent(node);
}

*result_node = NULL;
return false;
}
1 change: 1 addition & 0 deletions aps2scala/dump-scala.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern int verbose;
extern int debug;
extern bool include_comments;
extern bool static_scc_schedule;
extern bool anc_analysis;

class Implementation;

Expand Down
7 changes: 7 additions & 0 deletions codegen/dump.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef DUMP_H
#include "implement.h"
#include <iostream>
#include <string>
#include <vector>

using std::ostream;
using std::string;
Expand All @@ -13,6 +15,7 @@ void impl_module(const char *name, const char *type);

extern bool incremental;
extern bool static_schedule;
extern bool farrow_synth_improvements;
extern int verbose;
extern int debug;
extern bool include_comments;
Expand Down Expand Up @@ -196,4 +199,8 @@ inline const output_streams& operator<< <header_end>
}
#endif /* APS2SCALA */

// Common code generation utility functions
extern bool check_surrounding_decl(void* node, KEYTYPE_Declaration decl_key, Declaration* result_decl);
extern bool check_surrounding_node(void* node, KEYTYPE_ABSTRACT_APS_Phylum ast_key, void** result_node);

#endif
7 changes: 7 additions & 0 deletions codegen/implement.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,16 @@ class Implementation {
virtual void implement_value_use(Declaration vd, ostream&) = 0;
};

class SynthImplementation : public Implementation {
public:
virtual bool try_dump_funcall(Expression, ostream&) = 0;
virtual void dump_synth_instance(INSTANCE*, ostream&) = 0;
};

extern Implementation *dynamic_impl;
extern Implementation *static_impl;
extern Implementation *static_scc_impl;
extern Implementation *synth_impl;

#define IMPLEMENTATION_MARKS (127<<24)

Expand Down
Loading