Skip to content
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

Added support for _POSIX_MAPPED_FILES if defined in source #564

Merged
merged 2 commits into from
Mar 28, 2023
Merged

Added support for _POSIX_MAPPED_FILES if defined in source #564

merged 2 commits into from
Mar 28, 2023

Conversation

CoderRC
Copy link

@CoderRC CoderRC commented Mar 28, 2023

I have created my own library for mingw32 that includes the POSIX functions that the source needs to compile. That is how I will support llama.cpp for windows using mingw32 compilation in mys2. Compiled successfully using:
make LDFLAGS='-D_POSIX_MAPPED_FILES -lmingw32_extended'

I have created my own library for mingw32 that includes the POSIX functions that the source needs to compile.
That is how I will support llama.cpp for windows using mingw32 compilation in mys2.
Compiled successfully using:
make LDFLAGS='-D_POSIX_MAPPED_FILES -lmingw32_extended'
@anzz1
Copy link
Contributor

anzz1 commented Mar 28, 2023

Since you're one of the few using mingw32 , could you please look into this first ? #551

Where does the _POSIX_MAPPED_FILES get defined exactly?

@jart jart self-requested a review March 28, 2023 15:54
@jart
Copy link
Contributor

jart commented Mar 28, 2023

I'd be reluctant to merge this because mmap() is a mandatory feature.

   _POSIX_MAPPED_FILES
           Support for memory mapped files is mandatory in POSIX.1-2017.

           This facility provides for the mapping of regular files into the
           process address space.

           Both this facility and the Shared Memory Objects option provide
           shared access to memory objects in the process address space. The
           mmap() and munmap() functions provide the functionality of
           existing practice for mapping regular files. This functionality
           was deemed unnecessary, if not inappropriate, for embedded systems
           applications and is expected to be optional in subprofiles.

I have a working mmap() implementation now for MSVC which I intend to push soon. Would it be sufficient for your purposes if we just got rid of the MINGW #ifdef and assumed that Mingw users will supply their own mmap()?

@CoderRC
Copy link
Author

CoderRC commented Mar 28, 2023

Yes, mmap() is a mandatory feature in POSIX.1-2017, but not in older POSIX versions, and MSVC does not fully support POSIX.1-2017 and _POSIX_MAPPED_FILES is not defined in MSVC.

@jart
Copy link
Contributor

jart commented Mar 28, 2023

Would you be interested in sharing your feedback on the mmap() polyfill I've just added to the mmap branch? https://github.com/ggerganov/llama.cpp/blob/mmap/mmap.c

@CoderRC
Copy link
Author

CoderRC commented Mar 28, 2023

Sucessfully compiled mmap branch and sucessfully compiled resolved conflicts.
In msys2 with mingw32 gcc compiler using:
make LDFLAGS='-D_POSIX_MAPPED_FILES -lmingw32_extended'

@CoderRC
Copy link
Author

CoderRC commented Mar 28, 2023

My real goal of this pull request is if mmap exists then _POSIX_MAPPED_FILES will be defined due to POSIX and it overrides any implementation in mmap.h.

Copy link
Contributor

@jart jart left a comment

Choose a reason for hiding this comment

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

OK let's do it. Thank you for this change.

@jart jart merged commit c9c820f into ggml-org:mmap Mar 28, 2023
@CoderRC
Copy link
Author

CoderRC commented Mar 28, 2023

Thank you, I use https://github.com/CoderRC/libmingw32_extended to compile this, thanks.

@CoderRC CoderRC deleted the mmap branch March 28, 2023 21:34
Deadsg pushed a commit to Deadsg/llama.cpp that referenced this pull request Dec 19, 2023
AAbushady pushed a commit to AAbushady/llama.cpp that referenced this pull request Jan 27, 2024
* .sh script V1

* koboldcpp.sh polish

* koboldcpp.sh dist generator

* Include html's in dist

* RWKV in Linux Dist

* Lower dependency requirements

* Eliminate wget dependency

* More distinct binary name

I know its technically amd64, but I don't want to cause confusion among nvidia users.

* Use System OpenCL

Unsure how this will behave in the pyinstaller build, but pocl ended up CPU only. With a bit of luck the pyinstaller uses the one from the actual system if compiled in a system without opencl, while conda now includes it for that specific system.

* Add cblas dependency

Missing this causes compile failures on some system's

* ICD workaround

Ideally we find a better solution, but conda forces ICD and needs this for the successful compile. However, pyinstaller then embeds the ICD causing it to be limited to the system it was compiled for. By temporarily removing the ICD pyinstaller can't find it and everything remains functional. Ideally we do this on a pyinstaller level, but I could not find any good options to do so yet.

* Fix & Nocuda

* Automatically build Linux Binary

* Auto build on v tag

* Better on release

* Fix missing jobs:

* More distinct name

* I am to retro...

* Fix release upload

* Another upload attempt

* Another upload attempt

* Also rebuild on release edit

* Placebo commit to maybe fix CI

---------

Co-authored-by: root <root@DESKTOP-DQ1QRAG>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants