Skip to content

Refactor constructors#525

Draft
murphe67 wants to merge 29 commits intomainfrom
refactor-constructors
Draft

Refactor constructors#525
murphe67 wants to merge 29 commits intomainfrom
refactor-constructors

Conversation

@murphe67
Copy link
Collaborator

@murphe67 murphe67 commented Jul 12, 2025

PR for discussion of refactoring constructors, since currently we have handwritten ones which are called with no arguments, and few comments explaining what is happening.

I've done 3 passes here: speculation, custom buffer placement, and combine steering logic. For combine steering logic, I moved the pass into a fully standalone setup to demonstrate what that looks like. It's a lot of work with a good bit of folder overhead, and I think it is only justified for passes we want to selectively compile/build.

This means I think we kill the pass namespaces, and have the create function of every pass be in the dynamatic namespace or the dynamatic::experimental namespace. These functions are meant to be public, so this makes sense.

The classes representing each pass are then also all in the same namespace of dynamatic::impl or dynamatic::experimental::impl. However in the header files everything is class based, so the only name pollution is the name of the classes themselves (which is more or less the same as namespaces).

@murphe67 murphe67 force-pushed the refactor-constructors branch from 642cec2 to 70c6058 Compare July 12, 2025 13:10
Copy link
Collaborator Author

@murphe67 murphe67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments

Comment on lines +21 to +25
namespace ftd {

inline void registerAllPasses() {
registerHandshakeCombineSteeringLogic();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ftd passes are in ftd namespace

#ifndef FTD_INITALLPASSES_H
#define FTD_INITALLPASSES_H

#include "experimental/ftd/Transforms/Passes.h"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ftd is a fully separate mlir library inside of experimental

Comment on lines +1 to +4
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls)
add_public_tablegen_target(DynamaticFTDTransformsPassIncGen)
add_dependencies(dynamatic-headers DynamaticFTDTransformsPassIncGen)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runs the tablegen file to make the autogenerated code, makes "dynamatic-headers" depend on this tablegen file

Comment on lines +1 to +12
add_dynamatic_library(DynamaticFTDTransforms
HandshakeCombineSteeringLogic.cpp

DEPENDS
DynamaticFTDTransformsPassIncGen

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRTransformUtils
DynamaticSupport
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set up a link target for the cpp files in the ftd library

Comment on lines +31 to +42
namespace dynamatic {
namespace experimental {
namespace ftd {

// import auto-generated base class definition
#define GEN_PASS_DEF_HANDSHAKECOMBINESTEERINGLOGIC
#include "experimental/ftd/Transforms/Passes.h.inc"

} // namespace ftd
} // namespace experimental
} // namespace dynamatic

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the definitions of the autogenerated stuff goes in the cpp file

The pass needs to specify the position of the Speculation Units by
means of an input JSON file.
}];
let constructor = "dynamatic::experimental::speculation::createHandshakeSpeculation()";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not recommended to use, disables auto generation of constructors

Comment on lines +54 to +58
// TableGen Pass Options
// - std::string pred
// - unsigned outid
// - unsigned slot
// - type std::string
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these variable declarations are in auto-generated files I feel like we should add a comment of them so someone reading the file who does a ctrl f to find the declaration sees something

DynamaticLSQSizing
DynamaticSpeculation
DynamaticRigidification
DynamaticFTDTransforms
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link the cpp files in the ftd library

dynamatic::registerAllPasses();
dynamatic::tutorials::registerAllPasses();
dynamatic::experimental::registerAllPasses();
dynamatic::experimental::ftd::registerAllPasses();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

register the ftd passes

print("Simulator launching")
result = subprocess.run([
SIMULATE_SH, DYNAMATIC_ROOT, c_file_dir, out_dir, kernel_name
SIMULATE_SH, DYNAMATIC_ROOT, c_file_dir, out_dir, kernel_name, "", "false"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was to fix the speculation integration tests so I could check two of the passes I changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant