Skip to content

Commit

Permalink
[nvq++] Removes MLIR's memref dialect. (#2438)
Browse files Browse the repository at this point in the history
* [nvq++] Removes MLIR's `scf` dialect

We don't use this dialect and its presence is a historical artifact.
This change triggered the removal of two tests:

* `test/Quake/ghz.qke`
* `test/Quake/iqft.qke`

Both tests are a reminder of a past when we had to write quantum kernels
directly in MLIR because of a lack of frontend. Both no longer test
aything useful.

The commit modifies `test/Quake/canonical-2.qke`, which was only testing
the canonicalization of `cc.scope` operations. The new form is removes
the clutter, making the test more precise.

`test/Translate/ghz.qke` had to be modified because it uses MLIR's
`affined.for` and its conversion to LLVMDialect requires `scf.for`.

Signed-off-by: boschmitt <[email protected]>

* [nvq++] Remove MLIR's `affine` dialect.

We don't use this dialect. The removal triggered the removel of one
test:

* `test/Quake/ccnot.qke`

The test was not testing anything useful, only kernel inlining, which is
already covered in other tests. Furthermore, the test is misleading
because, contrary to what the kernel name might indicate, it is not
implementing a `ccnot`.

Signed-off-by: boschmitt <[email protected]>

* [nvq++] Removes MLIR's `memref` dialect.

We don't use this dialect. Most changes were to substitute `memref` ops
with `cc` ops in tests.

Signed-off-by: boschmitt <[email protected]>

---------

Signed-off-by: boschmitt <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Co-authored-by: Eric Schweitz <[email protected]>
  • Loading branch information
boschmitt and schweitzpgi authored Dec 18, 2024
1 parent 2284d54 commit 1a4f99e
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 130 deletions.
2 changes: 0 additions & 2 deletions include/cudaq/Optimizer/InitAllDialects.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"

namespace cudaq {

Expand All @@ -31,7 +30,6 @@ inline void registerAllDialects(mlir::DialectRegistry &registry) {
mlir::func::FuncDialect,
mlir::LLVM::LLVMDialect,
mlir::math::MathDialect,
mlir::memref::MemRefDialect,

// CUDA-Q dialects
cudaq::cc::CCDialect,
Expand Down
12 changes: 6 additions & 6 deletions test/Quake/lambda_kernel_exec.qke
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__lambda.main.canHa
%4 = arith.extsi %c0_i32_0 : i32 to i64
%5 = quake.extract_ref %1[%4] : (!quake.veq<?>, i64) -> !quake.ref
%16 = quake.mz %5 name "b" : (!quake.ref) -> !quake.measure
%alloca = memref.alloca() : memref<i1>
%alloca = cc.alloca i1
%6 = quake.discriminate %16 : (!quake.measure) -> i1
memref.store %6, %alloca[] : memref<i1>
%7 = memref.load %alloca[] : memref<i1>
cc.store %6, %alloca : !cc.ptr<i1>
%7 = cc.load %alloca : !cc.ptr<i1>
cc.if(%7) {
cc.scope {
%c1_i32_1 = arith.constant 1 : i32
Expand Down Expand Up @@ -67,9 +67,9 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__lambda.main.canHa
%5 = quake.extract_ref %1[%4] : (!quake.veq<?>,i64) -> !quake.ref
%16 = quake.mz %5 name "b" : (!quake.ref) -> !quake.measure
%6 = quake.discriminate %16 : (!quake.measure) -> i1
%alloca = memref.alloca() : memref<i1>
memref.store %6, %alloca[] : memref<i1>
%7 = memref.load %alloca[] : memref<i1>
%alloca = cc.alloca i1
cc.store %6, %alloca : !cc.ptr<i1>
%7 = cc.load %alloca : !cc.ptr<i1>
cc.if(%7) {
cc.scope {
%c1_i32_1 = arith.constant 1 : i32
Expand Down
Loading

0 comments on commit 1a4f99e

Please sign in to comment.