Skip to content

Commit

Permalink
Merge branch 'asplos' into asplos-jgm-readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmelber authored Apr 16, 2024
2 parents 7dede10 + 5304be5 commit 516f72f
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 91 deletions.
6 changes: 3 additions & 3 deletions programming_examples/ml/relu/run.lit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) Copyright 2023 Advanced Micro Devices, Inc.
// (c) Copyright 2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// REQUIRES: ryzen_ai, chess
Expand All @@ -7,5 +7,5 @@
// RUN: %python %S/aie2.py | aie-opt -cse -canonicalize -o ./aie.mlir
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-ipu --no-compile-host --xclbin-name=aie.xclbin --ipu-insts-name=insts.txt ./aie.mlir
// RUN: g++-13 %S/test.cpp -o test.exe -std=c++23 -Wall -I%S/../../../runtime_lib/test_lib %S/../../../runtime_lib/test_lib/test_utils.cpp %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
// RUN: XRT_HACK_UNSECURE_LOADING_XCLBIN=1 ./test.exe -x aie.xclbin -k MLIR_AIE -i insts.txt | FileCheck %s
// CHECK: PASS!
// RUN: ./test.exe -x aie.xclbin -k MLIR_AIE -i insts.txt | FileCheck %s
// CHECK: PASS!
45 changes: 5 additions & 40 deletions programming_examples/ml/relu/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,47 +94,12 @@ int main(int argc, const char *argv[]) {
// ------------------------------------------------------
// Get device, load the xclbin & kernel and register them
// ------------------------------------------------------
// Get a device handle
unsigned int device_index = 0;
auto device = xrt::device(device_index);
xrt::device device;
xrt::kernel kernel;

// Load the xclbin
if (verbosity >= 1)
std::cout << "Loading xclbin: " << vm["xclbin"].as<std::string>() << "\n";
auto xclbin = xrt::xclbin(vm["xclbin"].as<std::string>());

// Load the kernel
if (verbosity >= 1)
std::cout << "Kernel opcode: " << vm["kernel"].as<std::string>() << "\n";
std::string Node = vm["kernel"].as<std::string>();

// Get the kernel from the xclbin
auto xkernels = xclbin.get_kernels();
auto xkernel = *std::find_if(xkernels.begin(), xkernels.end(),
[Node, verbosity](xrt::xclbin::kernel &k) {
auto name = k.get_name();
if (verbosity >= 1) {
std::cout << "Name: " << name << std::endl;
}
return name.rfind(Node, 0) == 0;
});
auto kernelName = xkernel.get_name();

// Register xclbin
if (verbosity >= 1)
std::cout << "Registering xclbin: " << vm["xclbin"].as<std::string>()
<< "\n";
device.register_xclbin(xclbin);

// Get a hardware context
if (verbosity >= 1)
std::cout << "Getting hardware context.\n";
xrt::hw_context context(device, xclbin.get_uuid());

// Get a kernel handle
if (verbosity >= 1)
std::cout << "Getting handle to kernel:" << kernelName << "\n";
auto kernel = xrt::kernel(context, kernelName);
test_utils::init_xrt_load_kernel(device, kernel, verbosity,
vm["xclbin"].as<std::string>(),
vm["kernel"].as<std::string>());

// ------------------------------------------------------
// Initialize input/ output buffer sizes and sync them
Expand Down
14 changes: 7 additions & 7 deletions programming_examples/ml/vector_softmax/run.lit
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// (c) Copyright 2023 Advanced Micro Devices, Inc.
// (c) Copyright 2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// REQUIRES: ryzen_ai, chess
//
// RUN: aie-opt bf16_softmax.mlir --affine-super-vectorize="virtual-vector-size=16 test-fastest-varying=0 vectorize-reductions=true" --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc
// RUN: xchesscc_wrapper aie2 -I../../../../aie_runtime_lib/AIE2 -c dut.cc -o dut.o
// RUN: xchesscc_wrapper aie2 -I. -c ../../../../aie_runtime_lib/AIE2/lut_based_ops.cpp -o lut_based_ops.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../aie_kernels/aie2/softmax.cc -o softmax.o
// RUN: aie-opt %S/bf16_softmax.mlir --affine-super-vectorize="virtual-vector-size=16 test-fastest-varying=0 vectorize-reductions=true" --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc
// RUN: xchesscc_wrapper aie2 -I %aietools/include -I%S/../../../aie_runtime_lib/AIE2 -c dut.cc -o dut.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/../../../aie_runtime_lib/AIE2/lut_based_ops.cpp -o lut_based_ops.o
// RUN: xchesscc_wrapper aie2 -I %aietools/include -c %S/softmax.cc -o softmax.o
// RUN: ar rvs kernels.a dut.o lut_based_ops.o softmax.o
// RUN: %python %S/aie2.py | aie-opt -cse -canonicalize -o ./aie.mlir
// RUN: %python aiecc.py --xbridge --aie-generate-cdo --aie-generate-ipu --no-compile-host --xclbin-name=aie.xclbin --ipu-insts-name=insts.txt ./aie.mlir
// RUN: g++-13 %S/test.cpp -o test.exe -std=c++23 -Wall -I%S/../../../runtime_lib/test_lib %S/../../../runtime_lib/test_lib/test_utils.cpp %xrt_flags -lrt -lstdc++ -lboost_program_options -lboost_filesystem
// RUN: XRT_HACK_UNSECURE_LOADING_XCLBIN=1 ./test.exe -x aie.xclbin -k MLIR_AIE -i insts.txt | FileCheck %s
// CHECK: PASS!
// RUN: ./test.exe -x aie.xclbin -k MLIR_AIE -i insts.txt | FileCheck %s
// CHECK: PASS!
45 changes: 5 additions & 40 deletions programming_examples/ml/vector_softmax/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,47 +104,12 @@ int main(int argc, const char *argv[]) {
// ------------------------------------------------------
// Get device, load the xclbin & kernel and register them
// ------------------------------------------------------
// Get a device handle
unsigned int device_index = 0;
auto device = xrt::device(device_index);
xrt::device device;
xrt::kernel kernel;

// Load the xclbin
if (verbosity >= 1)
std::cout << "Loading xclbin: " << vm["xclbin"].as<std::string>() << "\n";
auto xclbin = xrt::xclbin(vm["xclbin"].as<std::string>());

// Load the kernel
if (verbosity >= 1)
std::cout << "Kernel opcode: " << vm["kernel"].as<std::string>() << "\n";
std::string Node = vm["kernel"].as<std::string>();

// Get the kernel from the xclbin
auto xkernels = xclbin.get_kernels();
auto xkernel = *std::find_if(xkernels.begin(), xkernels.end(),
[Node, verbosity](xrt::xclbin::kernel &k) {
auto name = k.get_name();
if (verbosity >= 1) {
std::cout << "Name: " << name << std::endl;
}
return name.rfind(Node, 0) == 0;
});
auto kernelName = xkernel.get_name();

// Register xclbin
if (verbosity >= 1)
std::cout << "Registering xclbin: " << vm["xclbin"].as<std::string>()
<< "\n";
device.register_xclbin(xclbin);

// Get a hardware context
if (verbosity >= 1)
std::cout << "Getting hardware context.\n";
xrt::hw_context context(device, xclbin.get_uuid());

// Get a kernel handle
if (verbosity >= 1)
std::cout << "Getting handle to kernel:" << kernelName << "\n";
auto kernel = xrt::kernel(context, kernelName);
test_utils::init_xrt_load_kernel(device, kernel, verbosity,
vm["xclbin"].as<std::string>(),
vm["kernel"].as<std::string>());

// ------------------------------------------------------
// Initialize input/ output buffer sizes and sync them
Expand Down
21 changes: 21 additions & 0 deletions programming_guide/assets/MultiDesign.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions programming_guide/assets/SingleDesign.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 516f72f

Please sign in to comment.