StratusLab / client

Command Line Interface (CLI) for StratusLab cloud services
Apache License 2.0
2 stars 1 forks source link

ensure cpu capabilities of physical machine are visible in virtual machines #152

Closed loomis closed 9 years ago

loomis commented 10 years ago

For certain numerical calculations having more advanced CPU capabilities can greatly enhance the performance of the application. For the SAGE platform, the following flags are important: sse4_1, sse4_2, popcnt, avx, and arch_perfmon. These are supported by the machines in the StratusLab reference infrastructure but the flags are not visible from VMs running on those machines.

Determine what configuration changes (for the physical machine or the VM descriptor files) need to be done to make those flags visible to the VMs.

loomis commented 10 years ago

Snippets from email exchanges:

All of the physical machines on the StratusLab infrastructure support the sse4_1, sse4_2, popcnt, and arch_perfmon extensions. The newer machines on the infrastructure also support avx. However these extensions are not currently exposed by the virtualization layer to virtual machines.

The virtualization software (QEMU/KVM, Libvirt) appears to support all of these extensions except the arch_perfmon extension. Changes to the virtual machine and/or libvirt configuration may make the supported extensions visible and usable. This would require investigation to determine if this is feasible and if so, what modifications are necessary in the configuration/software.

The first place to look for information is the element documentation on the libvirt website. This indicates what needs to be declared in the libvirt deployment descriptor for a virtual machine to enable certain features (or to allow the physical CPU to be leaked through to the VMs). However, I doubt that you’ll be able to make much progress on this. You’ll need to modify the deployment descriptor, which is generated by StratusLab and probably need access to the physical machine.

For whatever it's worth, here is one data point. If I run on my laptop Sage's virtual machine (the guest is CENTOS and is meant to be used with virtualbox) with qemu+kvm and direct access to the cpu, all flags appear (including arch_perfmon, avx, ...).

As a note to self, here is the sequence of instructions I used:

  wget http://www-ftp.lip6.fr/pub/math/sagemath/win/sage-6.2.ova
  tar xvf /opt/Sage/windows/sage-6.2.ova
  qemu-img convert sage-6.2-disk1.vmdk -O qcow2 sage-6.2-disk1.img
  qemu-img resize sage-6.2-disk1.img +10G
  qemu sage-6.2-disk1.img -machine type=pc,accel=kvm -cpu host

This starts a Sage notebook in which I typed:

  import os; os.system("cat /proc/cpuinfo")
loomis commented 9 years ago

The StratusLab cloud infrastructure at LAL has been modified to always use the -cpu host flags when starting VMs. This passes all of the host's CPU capabilities through to the VMs. A FAQ has also been added to the documentation explaining how to configure this.

loomis commented 9 years ago

Modifying the qemu startup file has the unfortunate consequence that the virtual machines are silently left running after a termination request. The change on the infrastructure has been reverted. A real solution is to create an option when starting a virtual machine to add the necessary flag to the VM descriptor.