Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dialect,backend: Experimental CSL dialect and printer #2592

Closed
wants to merge 86 commits into from

Conversation

dk949
Copy link
Collaborator

@dk949 dk949 commented May 15, 2024

An experimental implementation of the CSL dialect modeling the CSL language used by the Cerebras WSE based systems.

Also includes a backend generating the CSL language and a tool to split output of the backend into the files consumable by cslc.

Files will need to be moved to the experimental directory before merging

Currently implemented features:

Types

  • csl.ptr
  • csl.comptime_struct
  • csl.color
  • csl.string
  • csl.type

Attributes

  • csl.module_kind
  • csl.task_kind
  • csl.ptr_kind
  • csl.ptr_const

Ops

  • csl.module
  • csl.layout
  • csl.param
  • csl.import_module
  • csl.member_access
  • csl.member_call
  • csl.addressof
  • csl.func
  • csl.task
  • csl.call
  • csl.return
  • csl.export
  • csl.set_rectangle
  • csl.set_tile_code
  • csl.rpc
  • csl.get_color
  • csl.const_struct
  • csl.const_str
  • csl.const_type

Non-CSL ops supported by the printer

  • arith.Addf
  • arith.Addi
  • arith.Constant
  • arith.ExtFOp
  • arith.ExtSIOp
  • arith.ExtUIOp
  • arith.FPToSIOp
  • arith.IndexCastOp
  • arith.Mulf
  • arith.Muli
  • arith.SIToFPOp
  • arith.TruncFOp
  • arith.TruncIOp
  • memref.GetGlobal
  • memref.Global
  • memref.Load
  • memref.Store
  • scf.Yield

Previously discussed with @AntonLydike and @n-io

AntonLydike and others added 30 commits April 15, 2024 16:06
Added return type printing to the CSL function printer
Unlike `func.call`, `csl.call` can only have one result.
Reusing the same logic as MemberCallOp
Operations to represent CSL tasks. All three task kinds are represented
by the same op.

Control tasks not yet supported.
Most of the functionality is shared with FuncOp printer.

Tasks are immediately bound to their IDs when they are printed.
For now only local and data tasks are tested, because control tasks are
not yet implemented.
Moved the shared parts of FuncOp and TaskOp into a common superclass.
Where the name of the op needs to be mentioned in an error message, use
the `name` field instead.
Rather than `Data[EnumType]`.
Added `SpacedOpaqueSyntaxAttribute` as a base class.
Now printing the properties as well.
This module is nested within the top level builtin ModuleOp and is used
to differentiate between the layout module and the program module.

The same op is used for both, they are differentiated with the `kind`
attribute.
This script takes the output of xdsl-opt using the csl printer and
splits it into a layout program files.
Just a container for operations to delimit them from global operations.
dk949 added 14 commits May 9, 2024 09:05
Now `scf.for` with arguments and results work by using mutable
variables.
This is a port of gemv-01-complete-program from
https://github.com/Cerebras/csl-examples/ to MLIR.
Removed AttrSizedOperandSegments option from MemberCallOp and CallOp.
Verifying that `var_name` is set when `value` is set.
Fixed the printer after call and member_call were updated.
`sym_name` should be used for the name of the symbol, even if `var_name`
is provided.
Added a filecheck test which utilises all features implemented so far.
@dk949 dk949 added dialects Changes on the dialects backend Compiler backend in xDSL labels May 15, 2024
@dk949 dk949 self-assigned this May 15, 2024
}
}

// CHECK-NEXT: param memcpy_params : comptime_struct;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is missing the struct body, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a param declaration with no default. It corresponds to this csl.param op.

// CHECK-NEXT: comptime {
// CHECK-NEXT: @rpc(@get_data_task_id(LAUNCH));
// CHECK-NEXT: }
// CHECK-NEXT: // >>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<< //
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ohh, so this is the "boundary" between layout and program module?

AntonLydike pushed a commit that referenced this pull request May 15, 2024
This PR is first in a series trying to split #2592 into more reviewable
chunks.

Adding basic CSL type representations to the dialect.
AntonLydike pushed a commit that referenced this pull request Jun 3, 2024
… builtins (#2684)

This PR adds

* Types
    + `csl.color`
* Attributes
    + Boolean attribute
    + String attribute
* Operations
    + `csl.param`
    + `csl.const_struct`
    + `csl.set_tile_code`
    + `csl.set_rectangle`
    + `csl.get_color`
    + `csl.rpc`

It adds the last changes made in #2592, which can be closed when this is
merged.
@AntonLydike
Copy link
Collaborator

@dk949 is everything from this merged now?

@dk949
Copy link
Collaborator Author

dk949 commented Jun 7, 2024

@AntonLydike All except the csl-file-adapter.

Frankly, this was just a hack to get something compiling with cslc. Better suggestions for how to split the resulting CSL code into two files is welcome.

@superlopuh
Copy link
Member

What's the purpose of this PR? Is it to track ongoing work and unimplemented features in the csl dialect?

@dk949
Copy link
Collaborator Author

dk949 commented Jul 26, 2024

What's the purpose of this PR? Is it to track ongoing work and unimplemented features in the csl dialect?

It was used as a reference for early work on the CSL dialect. All features in here have been merged/substantially modified by other PRs. I think it can be closed now.

@dk949 dk949 closed this Jul 26, 2024
@dk949 dk949 deleted the david/csl-printer branch September 4, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Compiler backend in xDSL dialects Changes on the dialects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants