This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add printf op from SPIRV OpenCL extension set spec
ClosedPublic

Authored by drprajap on May 30 2023, 9:43 AM.

Details

Summary

This change adds op to support printf instruction from OpenCL extensions set.

This op helps writing out debug details from SPIRV kernel in a given format.

Diff Detail

Event Timeline

drprajap created this revision.May 30 2023, 9:43 AM
Herald added a project: Restricted Project. · View Herald Transcript
drprajap updated this revision to Diff 526826.May 30 2023, 3:44 PM

Fixed printf test

drprajap published this revision for review.May 30 2023, 3:48 PM
antiagainst accepted this revision.May 30 2023, 6:08 PM
This revision is now accepted and ready to land.May 30 2023, 6:08 PM
kuhar requested changes to this revision.May 30 2023, 6:58 PM
kuhar added inline comments.
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
79

IIRC Pure implies (1) no memory effects and (2) speculability. Are we sure that this is this the case with printf? Alternatively, would it make sense to remove this trait from the base class for all misc ops or to remove this class all together since it has a single use right now?

782–789

This summary is a bit long - would it make sense to punt some conte to description instead? We edited some auto-generated summaries already, so I don't think this would create a new precedent.

This revision now requires changes to proceed.May 30 2023, 6:58 PM
antiagainst added inline comments.May 30 2023, 10:04 PM
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
79

Ah, good catch. Thanks for spotting this! :)

drprajap added inline comments.May 31 2023, 12:45 PM
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
79

aah, my mistake! thanks for catching it. For adding separate base class, thought that was convention where other ops are grouped in some base class and actual op extends that. But seeing the printf Op usage, I can remove base.

782–789

Sure. I can move some to description.

drprajap updated this revision to Diff 527172.May 31 2023, 12:48 PM

Removed MiscOp base class and corrected traits

kuhar accepted this revision.EditedMay 31 2023, 12:54 PM

LGTM, thanks for the fixes! Just a few nits.

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
788

nit: unnecessary empty line?

792

nit: missing . at the end of the sentence (probably autogenerated but still)

808

nit: empty line

This revision is now accepted and ready to land.May 31 2023, 12:54 PM
drprajap updated this revision to Diff 527176.May 31 2023, 12:59 PM

minor formatting changes

LGTM, thanks for the fixes! Just a few nits.

Thanks for reviewing! Addressed those nits. I do not have merge access, could you please help merge this change?

kuhar added a comment.May 31 2023, 1:11 PM

LGTM, thanks for the fixes! Just a few nits.

Thanks for reviewing! Addressed those nits. I do not have merge access, could you please help merge this change?

Sure, what name and email would you like to use for the commit?

LGTM, thanks for the fixes! Just a few nits.

Thanks for reviewing! Addressed those nits. I do not have merge access, could you please help merge this change?

Sure, what name and email would you like to use for the commit?

Name: Dimple Prajapati
Email: dimpalben.r.prajapati@intel.com

Thank you so much!

This revision was automatically updated to reflect the committed changes.
kuhar added a comment.May 31 2023, 1:46 PM

Landed in https://reviews.llvm.org/rG8939b5f5d2f30186a72f4ad44480ee9978663998. I changed the commit title and fixed blankspace in the commit message to adhere to MLIR/SPIRV conventions.