Skip to content

Commit

Permalink
Merge branch 'asplos' into fixAddReduce
Browse files Browse the repository at this point in the history
  • Loading branch information
denolf authored Apr 15, 2024
2 parents 711f2ea + 03e631b commit ca6ab57
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
8 changes: 5 additions & 3 deletions runtime_lib/test_lib/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
#ifndef _TEST_UTILS_H_
#define _TEST_UTILS_H_

#include <boost/program_options.hpp>
#include <cmath>
#include <cstdint>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdfloat>
#include <string>
#include <vector>

#include <boost/program_options.hpp>
#include <cmath>

#include "xrt/xrt_device.h"
#include "xrt/xrt_kernel.h"

Expand Down Expand Up @@ -52,10 +52,12 @@ static inline std::int32_t random_int32_t(int32_t range = 0x10000) {
return (std::int32_t)rand() % range;
}

#if defined(__STDCPP_BFLOAT16_T__)
static inline std::bfloat16_t random_bfloat16_t(std::bfloat16_t scale,
std::bfloat16_t bias) {
return std::bfloat16_t((scale * (float)rand() / (float)(RAND_MAX)) + bias);
}
#endif

bool nearly_equal(float a, float b, float epsilon = 128 * FLT_EPSILON,
float abs_th = FLT_MIN);
Expand Down
79 changes: 79 additions & 0 deletions utils/build-mlir-aie-from-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
##===- utils/build-mlir-aie-from-wheels.sh - Build mlir-aie --*- Script -*-===##
#
# This file licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
##===----------------------------------------------------------------------===##
#
# This script builds mlir-aie given wheels installed <llvm mlir dir>.
# which is usually ./my_install/mlir if installed from the
# ./utils/quick_setup.sh script.
# Assuming they are all in the same subfolder, it would look like:
#
# build-mlir-aie.sh <llvm mlir dir> <build dir> <install dir>
#
# e.g. build-mlir-aie-from-wheels.sh ./my_install/mlir
#
# <build dir> - optional, mlir-aie/build dir name, default is 'build'
# <install dir> - optional, mlir-aie/install dir name, default is 'install'
#
##===----------------------------------------------------------------------===##

if [ "$#" -lt 1 ]; then
echo "ERROR: Needs at least 1 arguments for <llvm build dir>."
exit 1
fi

BASE_DIR=`realpath $(dirname $0)/..`
CMAKEMODULES_DIR=$BASE_DIR/cmake
echo "CMAKEMODULES_DIR: $CMAKEMODULES_DIR"

WHL_MLIR_DIR=`realpath $1`
echo "WHL_MLIR DIR: $WHL_MLIR_DIR"

BUILD_DIR=${2:-"build"}
INSTALL_DIR=${3:-"install"}
LLVM_ENABLE_RTTI=${LLVM_ENABLE_RTTI:OFF}

mkdir -p $BUILD_DIR
mkdir -p $INSTALL_DIR
cd $BUILD_DIR
#set -o pipefail
#set -e

CMAKE_CONFIGS="\
-GNinja \
-DCMAKE_PREFIX_PATH=${WHL_MLIR_DIR} \
-DVITIS_VPP=$(which v++) \
-DCMAKE_MODULE_PATH=${CMAKEMODULES_DIR}/modulesXilinx \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_INSTALL_PREFIX="../${INSTALL_DIR}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DAIE_ENABLE_BINDINGS_PYTHON=ON \
-DLLVM_ENABLE_RTTI=$LLVM_ENABLE_RTTI \
-DAIE_RUNTIME_TARGETS=x86_64 \
-DAIE_RUNTIME_TEST_TARGET=x86_64 "

if [ -x "$(command -v lld)" ]; then
CMAKE_CONFIGS="${CMAKE_CONFIGS} -DLLVM_USE_LINKER=lld"
fi

if [ -x "$(command -v ccache)" ]; then
CMAKE_CONFIGS="${CMAKE_CONFIGS} -DLLVM_CCACHE_BUILD=ON"
fi

cmake $CMAKE_CONFIGS .. 2>&1 | tee cmake.log
ninja 2>&1 | tee mlir-aie-ninja.log
ninja install 2>&1 | tee mlir-aie-ninja-install.log
success=$?

if [ ${success} -ne 0 ]
then
rm -rf ${INSTALL_DIR}/*
rm -rf ${BUILD_DIR}/*
popd; exit 4
fi

exit 0
2 changes: 1 addition & 1 deletion utils/quick_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if test -f "$VPP"; then
export PYTHONPATH=`realpath mlir_aie/python`:$PYTHONPATH
popd
python3 -m pip install --upgrade --force-reinstall -r python/requirements.txt
pushd reference_designs/ipu-xrt
pushd programming_examples
else
echo "Vitis not found! Exiting..."
fi

0 comments on commit ca6ab57

Please sign in to comment.