Vulkan SDK detects only 1 GPU at a time - c

I have an Optimus notebook (meaning it has two graphics cards; one integrated and one discrete (dedicated)). Both of them support Vulkan and I can use each of them individually on my code. But there is a problem, I can't list or use them both on the same program. I must select on which GPU it runs before running my code (on Windows: right click on "myProgram.exe" -> Run with graphics processor, on Linux: ./"myProgram" for integrated GPU and primusrun ./"myProgram" for discrete) and it detects only the one I run my code on even when both GPUs are active at the same time.
My GPUs are Intel UHD Graphics 630 and NVIDIA GeForce GTX 1050 Ti. I am using LunarG Vulkan SDK 1.1.92, Intel driver version 25.20.100.6326, NVIDIA driver version 416.32 on Windows and 415.25 on Linux. As C compiler and operating system, MSVC 1912 on Windows 10 and gcc 8.2.1 on Arch Linux. Vulkan runtime and ICD loaders are installed and I get the same result on both OSs.
Here is my code:
uint32_t deviceCount;
vkEnumeratePhysicalDevices(instance, &deviceCount, NULL);
printf("Found: %d\n", deviceCount);
VkPhysicalDevice *devices = malloc(deviceCount * sizeof(VkPhysicalDevice));
vkEnumeratePhysicalDevices(instance, &deviceCount, devices);
for(uint32_t deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
{
VkPhysicalDeviceProperties deviceProperties;
vkGetPhysicalDeviceProperties(devices[deviceIndex], &deviceProperties);
printf("%s\n", deviceProperties.deviceName);
}
Here is the outputs I get:
If I run on integrated GPU:
Found: 1
Intel(R) UHD Graphics 630
If I run on dedicated GPU:
Found: 1
GeForce GTX 1050 Ti
What I am expecting is:
Found: 2
Intel(R) UHD Graphics 630
GeForce GTX 1050 Ti
And I should be able to pick either of them to use on my program without hassling with some driver level code or setting it on my OS before running. Vulkan is relatively low level API after all. Is there any way to force list all of the active GPUs on my system?

I'm not sure what you mean by
If I run on integrated GPU
versus
If I run on dedicated GPU"...
If you're going into the nVidia control panel and specifying a target GPU for your application, then you're seeing pretty much what I would expect... only that GPU exposed to your app.
I believe what you should be doing is setting it to auto-detect, and then ensuring that you're exporting the "Optimus Aware" flag in your binary. You should have something like this in your test code
extern "C" {
_declspec(dllexport) uint32_t NvOptimusEnablement = 0x00000001;
}
That should either cause Vulkan to see both GPUs, or force your application to automatically see only the discrete GPU, but without you having to do anything in the control panel, not sure which.

Related

How to start a virtual machine guest armv8 on amd64 host with qemu

How to run a virtual machine with qemu on an Ubuntu 18.04 x86_64 host system, when I want the guest system to be ARMv8 (Raspberry Pi 3, more specifically interested in the Cortex A53 processor)?
Background:
I want to compile a project for a real machine with ARMv8 on the mentioned host system. Currently, this is done with cross compile directly in the host system. For many different reasons, I want to set up a virtual machine which compiles binaries (virtually) native for the ARMv8. The binaries need to be runable on the real ARMv8 machine later.
Apart from Qemu and the right qemu-system-aarch64 to be installed on the host system, there is an image of the operating system needed. Ideally the same as the one running on the real ARMv8 device. The Ubuntu IoT Core 18.04 64-bit is available at https://ubuntu.com/download/raspberry-pi and I saved it to a local folder with the name ubuntu18045arm64rpi3.img.xz.
After extracting it, I got the extracted image 'ubuntu18045arm64rpi3.img'
To start a virtual machine with the given image and the wanted architecture, I type this:
sudo qemu-system-aarch64 -m 1024 -cpu cortex-a53 -M virt -drive if=none,file=ubuntu18045arm64rpi3.img,id=hd0
which gives me a window like that:
Now my main questions are:
I expected a virtual machine to boot up, where I can install the OS from the given image. What did I do wrong or how to achieve this goal?
Later on, I want to install a compiler (if not already there) on the guest ARMv8 machine and compile my project there. Afterwards I plan to transfer the compiled binaries to the real ARMv8 machine and expect them to run without difficulties. Is this possible with the current approach?
You can't just pass a disk image to the aarch64 QEMU and have it boot. You need to either pass a kernel to boot, or a BIOS (probably UEFI) image (which can then read a kernel off a disk image).
This blog post has an example of running Debian on QEMU; getting Ubuntu booting is probably similar.
https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/
Your link is to a raspberry pi specific disk image -- since you are not asking QEMU to model a raspberry pi board I would recommend against using that. You want whatever Ubuntu provides as their most normal/generic aarch64 image. If you're going the "boot via UEFI" route then you want a disk image intended for SBSA/UEFI systems.
On your second question about portability of compiled binaries, this is the same as for any two Linux systems, really. If the two systems have the same OS/distro version (so they have the same library versions etc), and the same sets of runtime libraries installed, and you didn't tell the compiler to compile to use CPU features that the destination CPU doesn't have, then it should work.
Compiling inside this emulated setup is going to be significantly slower than either your current cross-compile setup or compiling the binaries directly on the real AArch64 hardware, incidentally.

Mac hardware to write Codename One native interfaces

I need a Mac to write a native Codename One interface for iOS. I would like to use it in the future for the same purpose. I need to be able to open with Xcode the native code generated by the build server, add the implementation in Objective-C of the native methods and test the code on my iPhone X, to connect to the Mac via usb.
I found the following refurbished computer, I would like to ask you a secure confirmation that it goes well for the above purposes, before buying it:
Model MacBook Pro 13″ (MacBookPro9,2) - A1278 - MD101LL/A - 2012
Intel Core i5 3210M "Ivy Bridge" 2.5GHz "Ivy Bridge" processor with turbo boost up to 3.1GHz
Installed Ram 8 GB PC3-12800 (1600 MHz) DDR3 SO-DIMM
Intel HD Graphics 4000 integrated video card - 1.5GB of shared video memory
Installed Hard Disk Drive 500GB SATA 2.5″ HDD
13.3 inch (diagonal) LED backlit display - 1280×800 pixels
Operating System macOS 10.15 Catalina
Keyboard Layout QWERTY US - International
2x USB 3.0, 2x Thunderbolt, 1x SD-card slot, 1x Jack 3.5″ Devices
Right now seems OK, my one serious concern is the SATA disk and not SSD. Up until recently I used the 2013 version with 16gb, SSD and i7 which is still a great machine (screen broke in a fall on hard tile floor).
I can't tell if it will work well in the future but for now the important line is:
Operating System macOS 10.15 Catalina
That's the latest. So it will be able to run the latest xcode which should be compatible for Codename One development for a while.
Since this is an 8 year old machine and Apple is transitioning to ARM devices don't expect more than 2 years from this machine though.
Another option you can consider is a Mac mini. They are often an amazing value for the money, even when new.

GPU ARM Mali and OpenCL driver

I have my TinkerBoard powered by an ARM-based Mali™-T764 GPU. I am running Debian linaro v2.0.8 strech.
I am looking for an OpenCL support, how can I enable the GPU MALI with OpenCL 1.2 FP?
If you can advice me to update it I would appreciate it.
You need to install the binary ARM Mali drivers. How you do that, depends on the distro you're using. On Odroids for example, it comes installed with their Ubuntu.
Once you have it installed, it either comes with OpenCL enabled, or you can simply enable it: create a file /etc/OpenCL/vendors/mali.icd and put inside that file the path to the driver, e.g. on my Odroid it's /usr/lib/arm-linux-gnueabihf/mali-egl/libmali.so
So first i'd ask on whatever communication channels Debian Linaro has, how to install the binary drivers.

OpenCL, my GPU it's not capable?

I have an old computer, then I don't know if I can execute OpenCL codes on my PC; I've checked my GPU and I get this output:
When I execute OpenCL code, I get this error:
Finally, if I run clinfo, i get this:
I really don't know..It's a problem of libraries?Or my GPU cannot execute OpenCL codes?
Your GPU predates OpenCL. Beignet supports Ivybridge and later (https://www.freedesktop.org/wiki/Software/Beignet/#supportedtargets).
Your CPU also predates OpenCL. Intel's first release of their CPU-only OpenCL driver requires SSE4.1, but your CPU only has SSE3. If you really really need to get OpenCL to work on this machine, you may be able to install an old version (2.8) of the AMD OpenCL CPU driver if you can find it. Quote from http://boinc.berkeley.edu/wiki/OpenclCpu:
Intel's OpenCL support requires the SSE4.1 CPU feature (BOINC's event log shows you the list of your CPU's features).
If your host does not have SSE4.1 support, then you can install the AMD APP SDK 2.8 and it will install the AMD OpenCL CPU driver. Note that the AMD APP SDK v2.9 will NOT install it. You have to use 2.8 or earlier as they now bundle the OpenCL driver with the video driver instead of with the APP SDK. As AMD only keeps the last several versions on their archive page, you may want to grab both the 32 and 64 bit version of the v2.8 APP SDK now and keep them in a safe place.
Or maybe POCL or FreeOCL might cover you for the CPU.

RTLinux on X86 PC

Preface:
Linux and RT is a new realm of discovery, as I am mostly familiar with the Windows environment & Visual Studio C++ development.
Goal:
Execute a few sample 'C' programs on RTLinux, for analysis of deadlines and timing.
Method:
I do not currently have a "target" hardware device. However, I do have a PC with an Intel Core i5.
Questions:
Can I install in a dual boot configuration to preserve my every day
Windows 7 configuration? Will it work with Ubuntu? This is my biggest concern unless I purchase another PC.
Can RTLinux install and execute correctly? I do see it supports x86
but has this been done successfully on a PC configuration - and does it have a GUI to work with?
Are there are reliable simulators that can run on Windows, bypassing installing the OS, that will give good benchmarks of
timing, say of a context switch?
Any other options to run sample programs on RTLinux that I may not be
aware of ?
You can install Ubuntu on a PC with Windows 7 but you will need a separate disk partition and things can go wrong. I have different versions of Ubuntu and other Linux 32 bit and 64 bit distros installed on USB sticks, USB disks and an eSATA disk. The USB devices, at least for Ubuntu, all boot successfully on my desktops and laptops. Booting time and details of my Linux programs are in the following. All are compiled and run from command lines, where commands are provided with the source codes that are free to download.
http://www.roylongbottom.org.uk/linux%20benchmarks.htm
The distros are copied to bootable USB sticks or CDs/DVDs. At least older releases of Ubuntu were easily installed on USB devices or on an hard disk partition but bootable from USB. For later ones, I installed the distros on a laptop, with the disk drive disconnected. Then you can’t go wrong.
I believe that RTLinux uses the same GCC compiler as other Linuxes.

Resources