VirtualPhotonics / VTS

Virtual Tissue Simulator
https://virtualphotonics.org
Other
34 stars 9 forks source link

Support ARM architecture #156

Open scottprahl opened 1 month ago

scottprahl commented 1 month ago

Is your feature request related to a problem? Please describe. I successfully built version 11 on a M3 Mac. However running mc leads to

dotnet6/host/fxr/6.0.29/libhostfxr.dylib (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

I somehow fixed this when running v10, but I don't have the time to track the solution down now.

Describe the solution you'd like All Apple devices would work better if the ARM architecture was supported. Obviously, including Android tablets running ARM would

Describe alternatives you've considered Using Rosetta was the old solution, but is suboptimal.

Additional context Perhaps this could combined with the transition to .NET 8? As you know, .NET 6 reaches end of support on Nov 12, 2024

lmalenfant commented 1 month ago

Hi Scott,

Thank you for reporting this issue, I don't have a Mac to test on but we usually have @janakarana run the MCCL on his Mac to make sure it is working correctly. As far as I know we have not modified the architecture that we use to create the zip file, is that the version you tried or were you building using BuildTestRelease? We did modify this file to allow us to create zip files for the libraries to include in the Python repository but the main MCCL BuildTestRelease should be the same as it as for version 10.

Are you suggesting that we change the publish for Mac from osx-x64 to osx-arm64?

scottprahl commented 1 month ago

Hi Lisa,

This is just about getting the MCCL binary to work on the ARM architecture. I am not sure how this will affect the .dlls that need to be created.

I suggest adding three new releases: osx-arm64, linux-arm64, and win-arm64. Keep the existing ones.

I added these build targets to the BuildTestReleaseMCCL.ps1 for macOS, linux, and Windows ARM64 architectures.

BuildTestReleaseMCCL.ps1.txt

All binaries built on my ARM-based Mac. When I ran mc in the publish/osx-arm64 directory, it worked fine with my installed ARM based .NET installation. The mc in the publish/osx-x64 complains with

fxr/6.0.32/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

at the end the publish directory contains

linux-arm64 linux-x64 local osx-arm64 osx-x64 win-arm64 win-x64

and release contains zip files for all these

MC_vx.xx.x_Linux_ARM64.zip MC_vx.xx.x_Mac_ARM64.zip MC_vx.xx.x_Win_ARM64.zip MC_vx.xx.x_Linux_x64.zip MC_vx.xx.x_Mac_x64.zip MC_vx.xx.x_Win_x64.zip

lmalenfant commented 1 month ago

I will discuss with @hayakawa16 this week about possibly adding all the architectures, do you think we need to do the same for the libraries used in the Python repository also?

Just a quick comment, the files in the "local" folder should have the architecture of the computer that is running BuildTestRelease, does that version of MCCL work for you also?

scottprahl commented 1 month ago

The binary mc in the local folder works!

I modified BuildTestReleaseScripting.ps1 to build separate files for ARM and intel. Turns out the .dll files for all the platforms are identical!

When you compile a .NET application, the code is not directly compiled into machine code. Instead, it is compiled into an Intermediate Language (IL), sometimes referred to as Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL). IL is a CPU-independent set of instructions that can be efficiently converted to native code.

This means that you probably only need one zip file for scripting!

lmalenfant commented 1 month ago

@scottprahl Thank you for doing that! That's good to know.