cengal_memory_barriers
Fast crossplatform memory barriers for Python.
Memory barriers are utilized by the operating system to implement synchronization primitives, such as Mutexes.
Advantages
Supported OS: at least ["Linux", "Darwin", "Windows"]. Supported targets: at least ["Emscripten", "ARM", "x86_64", "x86", "i386", "i686", "AMD64"]. "Other" system or target should have "stdatomic.h" header to be supported.
Installation
pip install cengal_memory_barriers
Documentation
Import
from cengal_memory_barriers import full_memory_barrier, mm_pause
Supported systems
| OS \ CPU: | x86 ("x86_64", "x86", "i386", "i686", "AMD64") | ARM | Emscripten | Other targets |
|---|---|---|---|---|
| Linux | + | + | + | + |
| Darwin | + | + | + | + |
| Windows | + | + | + | |
| Other systems with "stdatomic.h" header | + | + | + | + |
Available functions per system
| Func name: \ System: | Linux/Darwin (x86) | Linux/Darwin (ARM) | Windows (x86) | Windows (ARM) | Emscripten | Other systems with "stdatomic.h" header |
|---|---|---|---|---|---|---|
| full_memory_barrier() | + | + | + | + | + | + |
| memory_barrier() | + | + | + | + | + | + |
| sync_synchronize() | + | + | + | + | + | + |
| mm_pause() | + | + | + | + | + | + |
| mm_mfence() | + | + | + | + | + | + |
| mm_sfence() | + | + | + | + | + | + |
| mm_lfence() | + | + | + | + | + | + |
| mm_clflush(...) | + | + | ||||
| iso_volatile_store16(...) | + | |||||
| py_emscripten_atomic_fence() | + | |||||
| clear_cache(...) | + | + | ||||
| py_atomic_thread_fence(...) | + | + | + | + | ||
| py_atomic_thread_fence__*() | + | + | + | + |
Backend calls - Main functions
| System: \ Func name: | full_memory_barrier() |
memory_barrier() |
sync_synchronize() |
|---|---|---|---|
| Linux/Darwin (x86) | _mm_mfence() | _mm_mfence() | __sync_synchronize() |
| Linux/Darwin (ARM) | __sync_synchronize() | __sync_synchronize() | __sync_synchronize() |
| Windows (x86) | MemoryBarrier() | MemoryBarrier() | MemoryBarrier() |
| Windows (ARM) | MemoryBarrier() | MemoryBarrier() | MemoryBarrier() |
| Emscripten | emscripten_atomic_fence() | __sync_synchronize() | __sync_synchronize() |
| Other systems with "stdatomic.h" header | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) |
Backend calls - Secondary functions
| System: \ Func name: | mm_mfence() |
mm_sfence() |
mm_lfence() |
mm_pause() |
|---|---|---|---|---|
| Linux/Darwin (x86) | _mm_mfence() | _mm_sfence() | _mm_lfence() | _mm_pause() |
| Linux/Darwin (ARM) | __sync_synchronize() | __sync_synchronize() | __sync_synchronize() | pass |
| Windows (x86) | _mm_mfence() | _mm_sfence() | _mm_lfence() | _mm_pause() |
| Windows (ARM) | MemoryBarrier() | MemoryBarrier() | MemoryBarrier() | pass |
| Emscripten | __sync_synchronize() | __sync_synchronize() | __sync_synchronize() | pass |
| Other systems with "stdatomic.h" header | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) | pass |
Backend calls - Unique calls
| Func name: | Backend call: |
|---|---|
| mm_clflush(p: int) -> None | _mm_clflush(...) |
| iso_volatile_store16(p: int, val: int) -> None | __iso_volatile_store16(...) |
| py_emscripten_atomic_fence() -> None | emscripten_atomic_fence() |
| clear_cache(beg: int, end: int) -> None | __clear_cache(...) |
| py_atomic_thread_fence(order: int) -> None | atomic_thread_fence(...) |
| py_atomic_thread_fence__memory_order_relaxed() | atomic_thread_fence(MEMORY_ORDER_RELAXED) |
| py_atomic_thread_fence__memory_order_consume() | atomic_thread_fence(MEMORY_ORDER_CONSUME) |
| py_atomic_thread_fence__memory_order_acquire() | atomic_thread_fence(MEMORY_ORDER_ACQUIRE) |
| py_atomic_thread_fence__memory_order_release() | atomic_thread_fence(MEMORY_ORDER_RELEASE) |
| py_atomic_thread_fence__memory_order_acq_rel() | atomic_thread_fence(MEMORY_ORDER_ACQ_REL) |
| py_atomic_thread_fence__memory_order_seq_cst() | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) |
Alternatives description:
clear_cache(beg: int, end: int) -> None- "Linux", "Darwin" - An alternative tomm_clflush()in GCC and Clang compilersiso_volatile_store16(p: int, val: int) -> None- "Windows" - "ARM" - An alternative tomm_clflush()for ARM in Visual Studio compilerpy_emscripten_atomic_fence() -> None- "Emscripten" - Probably can be used as an alternative tomm_clflush()for Emscripten
Based on Cengal
Represents part of Cengal library:
An equivalent import:
from cengal.hardware.memory.barriers import full_memory_barrier, mm_pause
Cengal library can be installed by:
pip install cengal
Projects using Cengal
- flet_async - wrapper which makes Flet async and brings booth Cengal.coroutines and asyncio to Flet (Flutter based UI)
- justpy_containers - wrapper around JustPy in order to bring more security and more production-needed features to JustPy (VueJS based UI)
- Bensbach - decompiler from Unreal Engine 3 bytecode to a Lisp-like script and compiler back to Unreal Engine 3 bytecode. Made for a game modding purposes
- Realistic-Damage-Model-mod-for-Long-War - Mod for both the original XCOM:EW and the mod Long War. Was made with a Bensbach, which was made with Cengal
- SmartCATaloguer.com - TagDB based catalog of images (tags), music albums (genre tags) and apps (categories)
License
Copyright © 2012-2023 ButenkoMS. All rights reserved.
Licensed under the Apache License, Version 2.0.
Metadata
Release files for cengal-memory-barriers 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cengal_memory_barriers-2.1.0.tar.gz | 9.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cengal_memory_barriers-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / cengal_memory_barriers-2.1.0.tar.gz
| Download URL | cengal_memory_barriers-2.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2162ceb0b887deb1cb44cc12086b85f5e5117093f6b7168f8a9df30cdecab333
|
|
BLAKE2b-256 checksum How to use checksums |
28f752adbd1b881f1b380568082f2c586ee371f5d052406b3474c15ca6e483fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / cengal_memory_barriers-2.1.0-py3-none-any.whl
| Download URL | cengal_memory_barriers-2.1.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c30c30a2e25ba96ef4ada52ab38025a6dd2ff7a138ef6239b918d4248b69bcc
|
|
BLAKE2b-256 checksum How to use checksums |
fbeb8cefd894fdd2da8dbe14eddf17e803ea942dc246ac74428eadacea8ed055
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for cengal-memory-barriers 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.