cengal-memory-barriers


Namecengal-memory-barriers JSON
Version 2.1.0 PyPI version JSON
download
home_page
SummaryFast crossplatform memory barriers for Python
upload_time2023-11-22 22:45:30
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords amd64 arm armv7 armv8 emscripten ia-32 ia-64 ia_32 ia_64 intel64 barrier barriers cengal crossplatform hardware memory memory barrier memory barriers x86 x86-32 x86-64 x86_32 x86_64
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
pip install cengal_memory_barriers
```

# Documentation

## Import

```python
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 to `mm_clflush()` in GCC and Clang compilers
* `iso_volatile_store16(p: int, val: int) -> None` - "Windows" - "ARM" - An alternative to `mm_clflush()` for ARM in Visual Studio compiler
* `py_emscripten_atomic_fence() -> None` - "Emscripten" - Probably can be used as an alternative to `mm_clflush()` for Emscripten

# Based on Cengal

Represents part of Cengal library:
* https://pypi.org/project/cengal/
* https://github.com/FI-Mihej/Cengal

An equivalent import:
```python
from cengal.hardware.memory.barriers import full_memory_barrier, mm_pause
```

Cengal library can be installed by:

```bash
pip install cengal
```


# Projects using Cengal

* [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)
* [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)
* [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
* [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
* [SmartCATaloguer.com](http://www.smartcataloguer.com/index.html) - 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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cengal-memory-barriers",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "AMD64,ARM,ARMv7,ARMv8,Emscripten,IA-32,IA-64,IA_32,IA_64,Intel64,barrier,barriers,cengal,crossplatform,hardware,memory,memory barrier,memory barriers,x86,x86-32,x86-64,x86_32,x86_64",
    "author": "",
    "author_email": "ButenkoMS <gtalk@butenkoms.space>",
    "download_url": "https://files.pythonhosted.org/packages/28/f7/52adbd1b881f1b380568082f2c586ee371f5d052406b3474c15ca6e483fe/cengal_memory_barriers-2.1.0.tar.gz",
    "platform": null,
    "description": "# 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) -> None                     | _mm_clflush(...)                          |\n| iso_volatile_store16(p: int, val: int) -> None | __iso_volatile_store16(...)               |\n| py_emscripten_atomic_fence() -> None           | emscripten_atomic_fence()                 |\n| clear_cache(beg: int, end: int) -> None        | __clear_cache(...)                        |\n| py_atomic_thread_fence(order: int) -> 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) -> None` - \"Linux\", \"Darwin\" - An alternative to `mm_clflush()` in GCC and Clang compilers\n* `iso_volatile_store16(p: int, val: int) -> None` - \"Windows\" - \"ARM\" - An alternative to `mm_clflush()` for ARM in Visual Studio compiler\n* `py_emscripten_atomic_fence() -> 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 \u00a9 2012-2023 ButenkoMS. All rights reserved.\n\nLicensed under the Apache License, Version 2.0.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Fast crossplatform memory barriers for Python",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/FI-Mihej/cengal_memory_barriers"
    },
    "split_keywords": [
        "amd64",
        "arm",
        "armv7",
        "armv8",
        "emscripten",
        "ia-32",
        "ia-64",
        "ia_32",
        "ia_64",
        "intel64",
        "barrier",
        "barriers",
        "cengal",
        "crossplatform",
        "hardware",
        "memory",
        "memory barrier",
        "memory barriers",
        "x86",
        "x86-32",
        "x86-64",
        "x86_32",
        "x86_64"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fbeb8cefd894fdd2da8dbe14eddf17e803ea942dc246ac74428eadacea8ed055",
                "md5": "ec7c4bd59f75b10ef0e1f785cee21c22",
                "sha256": "2c30c30a2e25ba96ef4ada52ab38025a6dd2ff7a138ef6239b918d4248b69bcc"
            },
            "downloads": -1,
            "filename": "cengal_memory_barriers-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ec7c4bd59f75b10ef0e1f785cee21c22",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9108,
            "upload_time": "2023-11-22T22:45:27",
            "upload_time_iso_8601": "2023-11-22T22:45:27.850071Z",
            "url": "https://files.pythonhosted.org/packages/fb/eb/8cefd894fdd2da8dbe14eddf17e803ea942dc246ac74428eadacea8ed055/cengal_memory_barriers-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28f752adbd1b881f1b380568082f2c586ee371f5d052406b3474c15ca6e483fe",
                "md5": "37a4be3a79b9fdf1051be2fcc5352590",
                "sha256": "2162ceb0b887deb1cb44cc12086b85f5e5117093f6b7168f8a9df30cdecab333"
            },
            "downloads": -1,
            "filename": "cengal_memory_barriers-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "37a4be3a79b9fdf1051be2fcc5352590",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9887,
            "upload_time": "2023-11-22T22:45:30",
            "upload_time_iso_8601": "2023-11-22T22:45:30.122742Z",
            "url": "https://files.pythonhosted.org/packages/28/f7/52adbd1b881f1b380568082f2c586ee371f5d052406b3474c15ca6e483fe/cengal_memory_barriers-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-22 22:45:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FI-Mihej",
    "github_project": "cengal_memory_barriers",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cengal-memory-barriers"
}
        
Elapsed time: 0.14734s