-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathCompiledKernel.cpp
More file actions
36 lines (29 loc) · 1.45 KB
/
CompiledKernel.cpp
File metadata and controls
36 lines (29 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*******************************************************************************
* Copyright (c) 2022 - 2026 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. *
******************************************************************************/
#include "CompiledKernel.h"
namespace cudaq {
CompiledKernel::CompiledKernel(OpaquePtr<JitEngine> engine,
std::string kernelName, void (*entryPoint)(),
bool hasResult)
: engine(std::move(engine)), name(std::move(kernelName)),
entryPoint(entryPoint), hasResult(hasResult) {}
KernelThunkResultType
CompiledKernel::execute(const std::vector<void *> &rawArgs) const {
auto funcPtr = getEntryPoint();
if (hasResult) {
void *buff = const_cast<void *>(rawArgs.back());
return reinterpret_cast<KernelThunkResultType (*)(void *, bool)>(funcPtr)(
buff, /*client_server=*/false);
} else {
reinterpret_cast<void (*)()>(funcPtr)();
return {nullptr, 0};
}
}
void (*CompiledKernel::getEntryPoint() const)() { return entryPoint; }
const JitEngine &CompiledKernel::getEngine() const { return *engine; }
} // namespace cudaq