Skip to content

Add simple qemu run to CI #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pr_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,6 @@ jobs:
GPU:
needs: [Build]
uses: ./.github/workflows/gpu.yml
Qemu:
needs: [Build]
uses: ./.github/workflows/qemu.yml
126 changes: 126 additions & 0 deletions .github/workflows/qemu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Builds project on qemu with custom hmat settings
name: Qemu

on: workflow_call

env:
CI_BRANCH : "${{ github.head_ref || github.ref_name }}"

permissions:
contents: read

jobs:
qemu-build:
name: Qemu
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Install qemu
run: |
sudo apt update && sudo apt install -y qemu-system genisoimage qemu-utils
- name: Run ssh-keygen
run: ssh-keygen -b 4096 -N '' -f ~/.ssh/id_rsa
- name: Generate iso with user info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try this? https://github.com/oneapi-src/unified-memory-framework/pull/304/files#issuecomment-1981226379
It should be much simpler, cleaner, and easier to reproduce locally.

Copy link
Member Author

@igchor igchor Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave it for now? It is a temporary solution anyway (until we have a proper scripts so we can run them on self-hosted runners as well). Also, it should just work if you copy the content of the 'run' and execute it locally (only need to do that once to generate the iso).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KFilipek I think we can leave it as it is (since it is just working), as we will use this only to allow working on different predefined memspaces - we should still work on a final solution and replace this workflow when we are ready

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both cases it will work just simply as "copy-paste", but I understand your point of view. From my side, it looks okay.

run: |
pub_key=$(cat ~/.ssh/id_rsa.pub)

cat > user-data << EOF
#cloud-config

# Add a 'cxltest' user to the system with a password
users:
- default
- name: cxltest
gecos: CXL Test User
primary_group: wheel
groups: users
sudo: ALL=(ALL) NOPASSWD:ALL
lock_passwd: false
ssh-authorized-keys:
- $pub_key
shell: /usr/bin/bash

# Set local logins
chpasswd:
list: |
root:password
cxltest:password
expire: False
EOF

cat > meta-data << EOF
instance-id: cxl-test
local-hostname: cxl-test
EOF

sudo -Sk genisoimage -output ubuntu-cloud-init.iso -volid cidata -joliet -rock ./user-data ./meta-data
- name: Download ubuntu image
run: wget https://cloud-images.ubuntu.com/lunar/current/lunar-server-cloudimg-amd64.img
- name: Resize image
run: qemu-img resize ./lunar-server-cloudimg-amd64.img +4G
- name: Run qemu
run: |
sudo qemu-system-x86_64 \
-drive file=./lunar-server-cloudimg-amd64.img,format=qcow2,index=0,media=disk,id=hd \
-cdrom ./ubuntu-cloud-init.iso \
-machine q35,usb=off,hmat=on \
-enable-kvm \
-net nic -net user,hostfwd=tcp::2222-:22 \
-m 3G \
-smp 4 \
-object memory-backend-ram,size=1G,id=ram0 \
-object memory-backend-ram,size=1G,id=ram1 \
-object memory-backend-ram,size=1G,id=ram2 \
-numa node,nodeid=0,memdev=ram0,cpus=0-1 \
-numa node,nodeid=1,memdev=ram1,cpus=2-3 \
-numa node,nodeid=2,memdev=ram2,initiator=0 \
-numa dist,src=0,dst=0,val=10 \
-numa dist,src=0,dst=1,val=20 \
-numa dist,src=0,dst=2,val=17 \
-numa dist,src=1,dst=0,val=20 \
-numa dist,src=1,dst=1,val=10 \
-numa dist,src=1,dst=2,val=28 \
-numa dist,src=2,dst=0,val=17 \
-numa dist,src=2,dst=1,val=28 \
-numa dist,src=2,dst=2,val=10 \
-numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-latency,latency=10 \
-numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-bandwidth,bandwidth=10485760 \
-numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-latency,latency=20 \
-numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-bandwidth,bandwidth=5242880 \
-numa hmat-lb,initiator=0,target=2,hierarchy=memory,data-type=access-latency,latency=16 \
-numa hmat-lb,initiator=0,target=2,hierarchy=memory,data-type=access-bandwidth,bandwidth=1048576 \
-numa hmat-lb,initiator=1,target=0,hierarchy=memory,data-type=access-latency,latency=20 \
-numa hmat-lb,initiator=1,target=0,hierarchy=memory,data-type=access-bandwidth,bandwidth=5242880 \
-numa hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-latency,latency=10 \
-numa hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-bandwidth,bandwidth=10485760 \
-numa hmat-lb,initiator=1,target=2,hierarchy=memory,data-type=access-latency,latency=27 \
-numa hmat-lb,initiator=1,target=2,hierarchy=memory,data-type=access-bandwidth,bandwidth=1048576 \
-daemonize -display none
- name: Run ssh keyscan
run: |
set +e
ssh-keyscan -p 2222 -H 127.0.0.1 >> ~/.ssh/known_hosts
while [ $? -ne 0 ]
do
echo "Trying to connect..."
ps -aux | grep qemu
sleep 5
ssh-keyscan -p 2222 -H 127.0.0.1 >> ~/.ssh/known_hosts
done
- name: Run build on qemu
run: |
if [ ${{ github.event_name }} = 'pull_request' ]; then
CI_REPO="${{ github.event.pull_request.head.repo.full_name }}"
else
CI_REPO="$GITHUB_REPOSITORY"
fi

scp -P 2222 ${{github.workspace}}/scripts/qemu/run-build.sh [email protected]:/home/cxltest
ssh [email protected] -p 2222 -t "bash /home/cxltest/run-build.sh https://github.com/$CI_REPO ${{env.CI_BRANCH}}"
39 changes: 39 additions & 0 deletions scripts/qemu/run-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set -x
set -e

repo=$1
branch=$2

echo password | sudo -Sk apt update
echo password | sudo -Sk apt install -y git cmake gcc g++ numactl libnuma-dev libjemalloc-dev libtbb-dev libhwloc-dev

numactl -H

git clone $repo umf
cd umf
git checkout $branch

mkdir build
cd build

cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON \
-DUMF_ENABLE_POOL_TRACKING=ON \
-DUMF_FORMAT_CODE_STYLE=OFF \
-DUMF_DEVELOPER_MODE=ON \
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON \
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON \
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON \
-DUMF_BUILD_EXAMPLES=ON \
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF

make -j $(nproc)

ctest --output-on-failure