<commit_before>#!/bin/bash

BUILD_ROOT="$( mktemp -d )"
SRC_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKING_DIR=$PWD
DASH_JAY="-j $(getconf _NPROCESSORS_ONLN)"

err() {
    echo "${1-Died}." >&2
}

die() {
    err "$1"
    exit 1
}

pushd () {
    command pushd "$@" > /dev/null
}

popd () {
    command popd "$@" > /dev/null
}

function setupENV()
{
    sudo apt-get update
    sudo apt-get install dpkg-dev rpm doxygen libelf-dev rename
}

function buildHIP()
{
    pushd $BUILD_ROOT
    cmake $SRC_ROOT -DCMAKE_BUILD_TYPE=Release
    make $DASH_JAY
    make package
    cp hip-*.deb $WORKING_DIR
    sudo dpkg -i -B hip-base*.deb hip-hcc*.deb hip-sample*.deb hip-doc*.deb
    popd
    rm -rf $BUILD_ROOT
}

echo "Preparing build environment"
setupENV || die "setupENV failed"
echo "Building and installing HIP packages"
buildHIP || die "buildHIP failed"
echo "Finished building HIP packages"<commit_msg>SWDEV-267298 - update install script to build hip-rocclr<commit_after>#!/bin/bash

# Parse command-line options
# Option strings
SHORT=hr:
LONG=help,rocclr-src:
# read the options
OPTS=$(getopt --options $SHORT --long $LONG --name "$0" -- "$@")
if [ $? != 0 ] ; then echo "Failed to parse options...exiting." >&2 ; exit 1 ; fi

usage() {
    echo "Usage: $0 -r|--roccclr-src <PATH to the rocclr src>" ;
    exit 1;
}

[ $# -eq 0 ] && usage

eval set -- "$OPTS"

# extract options and their arguments into variables.
while true ; do
  case "$1" in
    -r | --rocclr-src )
      ROCCLR_DIR="$2"
      shift 2
      ;;
    -h | --help )
      usage
      shift
      ;;
    -- )
      shift
      break
      ;;
    *)
      echo "Internal error!"
      exit 1
      ;;
  esac
done

BUILD_ROOT="$( mktemp -d )"
SRC_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKING_DIR=$PWD
DASH_JAY="-j $(getconf _NPROCESSORS_ONLN)"

err() {
    echo "${1-Died}." >&2
}

die() {
    err "$1"
    exit 1
}

pushd () {
    command pushd "$@" > /dev/null
}

popd () {
    command popd "$@" > /dev/null
}

function setupENV()
{
    sudo apt-get update
    sudo apt-get install dpkg-dev rpm doxygen libelf-dev rename
}

function buildHIP()
{
    pushd $BUILD_ROOT
    OPENCL_RUNTIME="$BUILD_ROOT/opencl"
    mkdir $OPENCL_RUNTIME
    git clone https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/ $OPENCL_RUNTIME
    ROCCLR_BUILD_DIR="$BUILD_ROOT/rocclr_build"
    mkdir  $ROCCLR_BUILD_DIR
    pushd $ROCCLR_BUILD_DIR
    cmake $ROCCLR_DIR -DOPENCL_DIR=$OPENCL_RUNTIME -DCMAKE_BUILD_TYPE=Release
    make $DASH_JAY
    popd
    HIP_BUILD_DIR="$BUILD_ROOT/hip_build"
    mkdir $HIP_BUILD_DIR
    pushd $HIP_BUILD_DIR
    cmake $SRC_ROOT -DCMAKE_PREFIX_PATH="$ROCCLR_BUILD_DIR;/opt/rocm" -DCMAKE_BUILD_TYPE=Release
    make $DASH_JAY
    make package
    cp hip-*.deb $WORKING_DIR
    sudo dpkg -i -B hip-base*.deb hip-rocclr*.deb hip-sample*.deb hip-doc*.deb
    popd
    popd
    rm -rf $BUILD_ROOT
}

echo "Preparing build environment"
setupENV || die "setupENV failed"
echo "Building and installing HIP packages"
buildHIP || die "buildHIP failed"
echo "Finished building HIP packages"
{'fraction_non_alphanumeric': 0.1397745571658615, 'fraction_numerical': 0.008695652173913044, 'mean_word_length': 2.9974259974259976, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2033744', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1158, 'n_words': 293}