-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for passing a pointer to a struct. (#988)
Closes #351.
- Loading branch information
1 parent
a76a725
commit 9d74d12
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. * | ||
* All rights reserved. * | ||
* * | ||
* This source code and the accompanying materials are made available under * | ||
* the terms of the Apache License 2.0 which accompanies this distribution. * | ||
******************************************************************************/ | ||
|
||
// RUN: nvq++ --enable-mlir --emit-qir %s && cat struct_arg.qir.ll | \ | ||
// RUN: FileCheck %s ; rm struct_arg.qir.ll | ||
|
||
#include <cudaq.h> | ||
#include <iostream> | ||
|
||
struct baz { | ||
void operator()(cudaq::qubit &q) __qpu__ { x(q); } | ||
}; | ||
|
||
struct foo { | ||
template <typename CallableKernel> | ||
void operator()(CallableKernel &&func, int n) __qpu__ { | ||
cudaq::qreg q(n); | ||
func(q[0]); | ||
mz(q[0]); | ||
} | ||
}; | ||
|
||
// CHECK-LABEL: define void @_ZN3fooclI3bazEEvOT_i | ||
// CHECK-SAME: (i8* nocapture readnone %{{.*}}, {}* nocapture readnone %{{.*}}, i32 %{{.*}}) | ||
|
||
int main() { | ||
auto result = cudaq::sample(1000, foo{}, baz{}, 1); | ||
for (auto &&[bits, counts] : result) { | ||
std::cout << bits << " : " << counts << '\n'; | ||
} | ||
return 0; | ||
} |