64bit won't work on my older Xeon CPU

A place to report problems and bugs in SharpCap
Forum rules


If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs

Please also read about Troubleshooting USB Issues before posting.

*** Please do not post license keys - please report any problems with licensing to 'admin' by private message ***

Please include the following details in any bug report:

* Version of SharpCap
* Camera and other hardware being user
* Operating system version
* Contents of the SharpCap log after the problem has occurred.
[If SharpCap crashes, please send the bug report when prompted instead of including the log]
Post Reply
Broke Astronomer
Posts: 2
Joined: Thu Jul 09, 2020 10:32 pm

64bit won't work on my older Xeon CPU

Post by Broke Astronomer »

I have an older Xeon 6 core 12 thread cpu that is pretty good for an astronomy PC in my observatory. I use it with everything except 64bit Sharpcap because it generates an error message saying it is not compatible with my instruction set.

Any way to add back in support for these old CPU's?

"Your CPU does not appear to support the AVX instruction set, which the 64-bit version of Sharpcap crrently requires"
User avatar
admin
Site Admin
Posts: 6974
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: 64bit won't work on my older Xeon CPU

Post by admin »

Hi,

I've tried a couple of times to make this work correctly, and despite investing quite a bit of effort into it haven't made it work so far. It's a bit annoying, because it's supposed to only use those instructions when they are present, but the system also seems to want to use them for general housekeeping code, and I haven't yet worked out how to get the bits that I want without the bits that I don't want :(

Cheers, Robin
drjustice
Posts: 3
Joined: Fri Jul 09, 2021 6:09 am

Re: 64bit won't work on my older Xeon CPU

Post by drjustice »

Hi,

I just bought a new long-battery life laptop based on a low-power intel N5030 CPU, and I have the same issue, same message.

I get the same message, except my cpu is like a 2019-2020 cpu ! Let's say I did not expect this.

Has there been any progress on this?

BTW I am also a software developer (C++ mostly) with pretty good experience in image processing, so if you need help fixing this issue for x64 I could probably lend a hand for free to rid the software of avx requirements.

PM or email me if interested.
User avatar
admin
Site Admin
Posts: 6974
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: 64bit won't work on my older Xeon CPU

Post by admin »

Hi,

the problem is buried deep in OpenCV, which SharpCap uses for image processing (see https://github.com/opencv/opencv/issues/15690 and related issues), which could be fixed by turning off the AVX support, but that sacrifices performance for the vast majority of users who do have AVX support. I'm kind of reluctant to do that, since the fraction with no AVX will drop even more as time passes.

Basically the way OpenCV does AVX etc is a bit rubbish - they recompile a bunch of code under different CPU settings in different namespaces and then link them all together. In theory that should only run AVX code on AVX CPUs, but they missed the fact that some of the code they recompile uses the STL, meaning that you get code generation for common STL functions in all sorts of CPU settings. The linker is then free to pick any implementation if there are multiple ones, since the rules of C++ say they should all be the same. For some reason, in X64 it seems to pick the AVX implementation of something like std::vector::resize(), which uses AVX instructions, which crashes on loading the DLL.

I would be happy to try building a trial version of the required DLL without AVX to see if that works for you - however the difficulty is how to update this on a version by version basis.

thanks,

Robin
drjustice
Posts: 3
Joined: Fri Jul 09, 2021 6:09 am

Re: 64bit won't work on my older Xeon CPU

Post by drjustice »

Sorry about the delayed response.

Well, it's true that many users have CPUs that support AVX, however there are still many telescope-mounted computers that are still using CPUs that don't support AVX. My brand new J4125 MeLE Quieter2, is one such example. My super-lightweight N5030 laptop is another. And any of the low-power, even brand-new Celerons built on the N6000 platform, are yet another. So I think it would be worthwhile to fix this issue for what's still a large proportion of users.

Anyway, about solutions to this issue.

It seems that there is only 1 x64 problematic DLL and it is so because happens to link with functions that use AVX instructions, for reasons you have stated above. It also seems possible to compile the whole DLL without AVX, but you fear this would impact users that have CPUs that support AVX. Fair enough.

So, I see a couple of ways around this issue.

1) Fight the compiler and try to build a single DLL that will properly detect which methods to use. This seems like a high-effort-low-return kind of proposition.

2) Create a separate x64-no-AVX Sharpcap release (alongside the normal x64 vs x86 releases). Users that don't have AVX can get the warning message, download the correct x64 version. Although "easy", that might be a bit of an overkill solution for only 1 problematic DLL.

3) Build an AVX and a non-AVX DLL and bundle both with the x64 installer. At program start, detect AVX support, and perform a LoadLibrary of the correct (AVX vs non-AVX) DLL. This will require you to perform manual function resolution using GetProcAddress() for the functions that you want to call, so that's a bit of a pain.

4) Build an AVX and a non-AVX DLL and bundle both with the x64 installer. Copy both DLLs to the installation folder. At first start, detect AVX support, and rename the correct DLL to the one the program is looking for. To do this, you might need to compiled the DLL with /DELAYLOAD so that you can rename the DLL with the correct name before it's loaded for use.

5) Build an AVX and a non-AVX DLL and bundle both with the x64 installer. At install time, detect if the CPU has AVX support, and decide which DLL should be installed into the application folder.


As for supporting this on a version-by-version basis, well, of course it would need to be part of your build system, but it certainly could be automated and completely transparent.

Me, I would choose #5.
User avatar
admin
Site Admin
Posts: 6974
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: 64bit won't work on my older Xeon CPU

Post by admin »

Hi,

I think I would probably go with #3 - there is a trick here... Windows will only ever load one copy of a DLL with a specific name, so if you create two copies and put them in separate folders, both called 'ProblemWithAvx.dll', all you have to do is LoadLibrary() the correct one before anything else tries to load it. From that point on, Windows will see requests for that DLL and do nothing because it is already loaded.

I need to catch up on a few other things first, but will put this on the to-do list.

cheers,

Robin
drjustice
Posts: 3
Joined: Fri Jul 09, 2021 6:09 am

Re: 64bit won't work on my older Xeon CPU

Post by drjustice »

Great, no rush.

BTW you don't need to load two libraries with the same name.

You can put ProblemDLLWithAvx.dll (A), and ProblemDLLWithoutAvx.dll (B), and what you do is call LoadLibrary on either DLL A, or DLL B depending on whether you detect AVX or not.

LoadLibrary just takes a string (the name of the DLL) so it's easy to decide which one you load.
User avatar
admin
Site Admin
Posts: 6974
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: 64bit won't work on my older Xeon CPU

Post by admin »

Hi,

I think I have a version that will work with no AVX. So far I have not seen a significant performance drop in my testing, so I will start with just that version for now and re-introduce an optional AVX enabled version if required. Fortunately VirtualBox has a way of configuring what instruction sets are available inside the virtual machine, which allows me to test (as I no longer have any CPUs that do not support AVX). You just have to hold your nose a bit at the idea of installing anything from Oracle on your PC... :)

cheers,

Robin
Splunge
Posts: 1
Joined: Wed Jul 28, 2021 8:12 pm

Re: 64bit won't work on my older Xeon CPU

Post by Splunge »

Robin,

I can confirm that the latest version of SharpCap 64 bit works on non-AVX hardware (Chuwi Larkbox in this case). Thanks for making that happen!

Regards,
Post Reply