{"id":17372880,"url":"https://github.com/fi-mihej/cengal_memory_barriers","last_synced_at":"2025-06-20T13:36:32.955Z","repository":{"id":208131340,"uuid":"720893909","full_name":"FI-Mihej/cengal_memory_barriers","owner":"FI-Mihej","description":"Fast crossplatform memory barriers for Python.","archived":false,"fork":false,"pushed_at":"2023-11-24T00:26:49.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T06:51:02.967Z","etag":null,"topics":["amd64","arm","arm64","armv7","armv8","barrier","barriers","cengal","crossplatform","emscripten","hardware","library","memory","memory-barriers","python","python-3","python3","x86","x86-32","x86-64"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/cengal-memory-barriers/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FI-Mihej.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-19T22:46:52.000Z","updated_at":"2023-11-20T04:11:50.000Z","dependencies_parsed_at":"2023-12-16T00:13:40.436Z","dependency_job_id":"0b333eb6-ab4e-4673-aa41-19d426ba5fd2","html_url":"https://github.com/FI-Mihej/cengal_memory_barriers","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"cb8a548f29b95008259e4d814cacfbcc7a5328a1"},"previous_names":["fi-mihej/cengal_memory_barriers"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/FI-Mihej/cengal_memory_barriers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FI-Mihej%2Fcengal_memory_barriers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FI-Mihej%2Fcengal_memory_barriers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FI-Mihej%2Fcengal_memory_barriers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FI-Mihej%2Fcengal_memory_barriers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FI-Mihej","download_url":"https://codeload.github.com/FI-Mihej/cengal_memory_barriers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FI-Mihej%2Fcengal_memory_barriers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260953944,"owners_count":23088129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd64","arm","arm64","armv7","armv8","barrier","barriers","cengal","crossplatform","emscripten","hardware","library","memory","memory-barriers","python","python-3","python3","x86","x86-32","x86-64"],"created_at":"2024-10-16T02:04:33.122Z","updated_at":"2025-06-20T13:36:27.942Z","avatar_url":"https://github.com/FI-Mihej.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cengal_memory_barriers\n\nFast crossplatform memory barriers for Python.\n\nMemory barriers are utilized by the operating system to implement synchronization primitives, such as Mutexes.\n\n# Advantages\n\nSupported 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.\n\n# Installation\n\n```bash\npip install cengal_memory_barriers\n```\n\n# Documentation\n\n## Import\n\n```python\nfrom cengal_memory_barriers import full_memory_barrier, mm_pause\n```\n\n## Supported systems\n\n| OS \\ CPU:                               | x86 (\"x86_64\", \"x86\", \"i386\", \"i686\", \"AMD64\") | ARM | Emscripten | Other targets |\n|-----------------------------------------|------------------------------------------------|-----|------------|---------------|\n| Linux                                   | +                                              | +   | +          | +             |\n| Darwin                                  | +                                              | +   | +          | +             |\n| Windows                                 | +                                              | +   | +          |               |\n| Other systems with \"stdatomic.h\" header | +                                              | +   | +          | +             |\n\n## Available functions per system\n\n| Func name: \\ System:         | Linux/Darwin (x86) | Linux/Darwin (ARM) | Windows (x86) | Windows (ARM) | Emscripten | Other systems with \"stdatomic.h\" header |\n|------------------------------|--------------------|--------------------|---------------|---------------|------------|-----------------------------------------|\n| full_memory_barrier()        | +                  | +                  | +             | +             | +          | +                                       |\n| memory_barrier()             | +                  | +                  | +             | +             | +          | +                                       |\n| sync_synchronize()           | +                  | +                  | +             | +             | +          | +                                       |\n|                              |                    |                    |               |               |            |                                         |\n| mm_pause()                   | +                  | +                  | +             | +             | +          | +                                       |\n| mm_mfence()                  | +                  | +                  | +             | +             | +          | +                                       |\n| mm_sfence()                  | +                  | +                  | +             | +             | +          | +                                       |\n| mm_lfence()                  | +                  | +                  | +             | +             | +          | +                                       |\n|                              |                    |                    |               |               |            |                                         |\n| mm_clflush(...)              | +                  |                    | +             |               |            |                                         |\n| iso_volatile_store16(...)    |                    |                    |               | +             |            |                                         |\n| py_emscripten_atomic_fence() |                    |                    |               |               | +          |                                         |\n| clear_cache(...)             | +                  | +                  |               |               |            |                                         |\n| py_atomic_thread_fence(...)  | +                  | +                  |               |               | +          | +                                       |\n| py_atomic_thread_fence__*()  | +                  | +                  |               |               | +          | +                                       |\n\n## Backend calls - Main functions\n\n| System: \\ Func name:                    | `full_memory_barrier()`                   | `memory_barrier()`                        | `sync_synchronize()`                      |\n|-----------------------------------------|-------------------------------------------|-------------------------------------------|-------------------------------------------|\n| Linux/Darwin (x86)                      | _mm_mfence()                              | _mm_mfence()                              | __sync_synchronize()                      |\n| Linux/Darwin (ARM)                      | __sync_synchronize()                      | __sync_synchronize()                      | __sync_synchronize()                      |\n| Windows (x86)                           | MemoryBarrier()                           | MemoryBarrier()                           | MemoryBarrier()                           |\n| Windows (ARM)                           | MemoryBarrier()                           | MemoryBarrier()                           | MemoryBarrier()                           |\n| Emscripten                              | emscripten_atomic_fence()                 | __sync_synchronize()                      | __sync_synchronize()                      |\n| 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) |\n\n## Backend calls - Secondary functions\n\n| System: \\ Func name:                    | `mm_mfence()`                             | `mm_sfence()`                             | `mm_lfence()`                             | `mm_pause()` |\n|-----------------------------------------|-------------------------------------------|-------------------------------------------|-------------------------------------------|--------------|\n| Linux/Darwin (x86)                      | _mm_mfence()                              | _mm_sfence()                              | _mm_lfence()                              | _mm_pause()  |\n| Linux/Darwin (ARM)                      | __sync_synchronize()                      | __sync_synchronize()                      | __sync_synchronize()                      | pass         |\n| Windows (x86)                           | _mm_mfence()                              | _mm_sfence()                              | _mm_lfence()                              | _mm_pause()  |\n| Windows (ARM)                           | MemoryBarrier()                           | MemoryBarrier()                           | MemoryBarrier()                           | pass         |\n| Emscripten                              | __sync_synchronize()                      | __sync_synchronize()                      | __sync_synchronize()                      | pass         |\n| 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         |\n\n## Backend calls - Unique calls\n\n| Func name:                                     | Backend call:                             |\n|------------------------------------------------|-------------------------------------------|\n| mm_clflush(p: int) -\u003e None                     | _mm_clflush(...)                          |\n| iso_volatile_store16(p: int, val: int) -\u003e None | __iso_volatile_store16(...)               |\n| py_emscripten_atomic_fence() -\u003e None           | emscripten_atomic_fence()                 |\n| clear_cache(beg: int, end: int) -\u003e None        | __clear_cache(...)                        |\n| py_atomic_thread_fence(order: int) -\u003e None     | atomic_thread_fence(...)                  |\n| py_atomic_thread_fence__memory_order_relaxed() | atomic_thread_fence(MEMORY_ORDER_RELAXED) |\n| py_atomic_thread_fence__memory_order_consume() | atomic_thread_fence(MEMORY_ORDER_CONSUME) |\n| py_atomic_thread_fence__memory_order_acquire() | atomic_thread_fence(MEMORY_ORDER_ACQUIRE) |\n| py_atomic_thread_fence__memory_order_release() | atomic_thread_fence(MEMORY_ORDER_RELEASE) |\n| py_atomic_thread_fence__memory_order_acq_rel() | atomic_thread_fence(MEMORY_ORDER_ACQ_REL) |\n| py_atomic_thread_fence__memory_order_seq_cst() | atomic_thread_fence(MEMORY_ORDER_SEQ_CST) |\n\nAlternatives description:\n* `clear_cache(beg: int, end: int) -\u003e None` - \"Linux\", \"Darwin\" - An alternative to `mm_clflush()` in GCC and Clang compilers\n* `iso_volatile_store16(p: int, val: int) -\u003e None` - \"Windows\" - \"ARM\" - An alternative to `mm_clflush()` for ARM in Visual Studio compiler\n* `py_emscripten_atomic_fence() -\u003e None` - \"Emscripten\" - Probably can be used as an alternative to `mm_clflush()` for Emscripten\n\n# Based on Cengal\n\nRepresents part of Cengal library:\n* https://pypi.org/project/cengal/\n* https://github.com/FI-Mihej/Cengal\n\nAn equivalent import:\n```python\nfrom cengal.hardware.memory.barriers import full_memory_barrier, mm_pause\n```\n\nCengal library can be installed by:\n\n```bash\npip install cengal\n```\n\n\n# Projects using Cengal\n\n* [flet_async](https://github.com/FI-Mihej/flet_async) - wrapper which makes [Flet](https://github.com/flet-dev/flet) async and brings booth Cengal.coroutines and asyncio to Flet (Flutter based UI)\n* [justpy_containers](https://github.com/FI-Mihej/justpy_containers) - wrapper around [JustPy](https://github.com/justpy-org/justpy) in order to bring more security and more production-needed features to JustPy (VueJS based UI)\n* [Bensbach](https://github.com/FI-Mihej/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\n* [Realistic-Damage-Model-mod-for-Long-War](https://github.com/FI-Mihej/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\n* [SmartCATaloguer.com](http://www.smartcataloguer.com/index.html) - TagDB based catalog of images (tags), music albums (genre tags) and apps (categories)\n\n# License\n\nCopyright © 2012-2024 ButenkoMS. All rights reserved.\n\nLicensed under the Apache License, Version 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi-mihej%2Fcengal_memory_barriers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffi-mihej%2Fcengal_memory_barriers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi-mihej%2Fcengal_memory_barriers/lists"}