licenses
sequencelengths 1
3
| version
stringclasses 677
values | tree_hash
stringlengths 40
40
| path
stringclasses 1
value | type
stringclasses 2
values | size
stringlengths 2
8
| text
stringlengths 25
67.1M
| package_name
stringlengths 2
41
| repo
stringlengths 33
86
|
---|---|---|---|---|---|---|---|---|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 877 | # Theme: Bulma Grid
Given demos organized as following, you can make them displayed in grid-like manner. This is like
the [`"grid"` theme](@ref theme-grid) but uses the [Bulma](https://bulma.io/) CSS framework and is
shipped with [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl).
```text
bulmagrid
βββ assets
βΒ Β βββ logo.svg
βββ config.json
βββ bulmagrid_section_1
βΒ Β βββ bulmagrid_subsection_1
βΒ Β βΒ Β βββ bulmagrid_card_1.md
βΒ Β βΒ Β βββ bulmagrid_card_2.md
βΒ Β βββ bulmagrid_subsection_2
βΒ Β βββ bulmagrid_card_3.md
βΒ Β βββ bulmagrid_card_4.md
βββ index.md
```
```julia
bulmagrid_demopage, bulmagrid_cb, bulmagrid_assets = makedemos("theme_gallery/bulmagrid", bulmagrid_templates)
```
The page configuration file `bulmagrid/config.json` should contain an entry `theme = "bulmagrid"`, e.g.,
```json
{
"theme": "bulmagrid"
}
```
{{{democards}}}
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 669 | # [Theme: Grid](@id theme-grid)
A basic DemoCards theme for grid-like layout.
Given demos organized as following, you can make them displayed in grid-like manner
```text
grid
βββ assets
βΒ Β βββ logo.svg
βββ config.json
βββ grid_section_1
βΒ Β βββ grid_subsection_1
βΒ Β βΒ Β βββ grid_card_1.md
βΒ Β βΒ Β βββ grid_card_2.md
βΒ Β βββ grid_subsection_2
βΒ Β βββ grid_card_3.md
βΒ Β βββ grid_card_4.md
βββ index.md
```
```julia
grid_demopage, grid_cb, grid_assets = makedemos("theme_gallery/grid", grid_templates)
```
The page configuration file `grid/config.json` should contain an entry `theme = "grid"`, e.g.,
```json
{
"theme": "grid"
}
```
{{{democards}}}
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 652 | # Theme: List
A basic DemoCards theme for list-like layout.
Given demos organized as following, you can make them displayed as a list of charts
```text
list
βββ assets
βΒ Β βββ logo.svg
βββ config.json
βββ list_section_1
βΒ Β βββ list_subsection_1
βΒ Β βΒ Β βββ list_card_1.md
βΒ Β βΒ Β βββ list_card_2.md
βΒ Β βββ list_subsection_2
βΒ Β βββ list_card_3.md
βΒ Β βββ list_card_4.md
βββ index.md
```
```julia
list_demopage, list_cb, list_assets = makedemos("theme_gallery/grid", list_templates)
```
The page configuration file `list/config.json` should contain an entry `theme = "list"`, e.g.,
```json
{
"theme": "list"
}
```
{{{democards}}}
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 787 | # Theme: No-cover List
A basic DemoCards theme for list-like without cover images layout.
Given demos organized as following, you can make them displayed as a list of charts
```text
nocoverlist
βββ assets
βΒ Β βββ logo.svg
βββ config.json
βββ nocoverlist_section_1
βΒ Β βββ nocoverlist_subsection_1
βΒ Β βΒ Β βββ nocoverlist_card_1.md
βΒ Β βΒ Β βββ nocoverlist_card_2.md
βΒ Β βββ nocoverlist_subsection_2
βΒ Β βββ nocoverlist_card_3.md
βΒ Β βββ nocoverlist_card_4.md
βββ index.md
```
```julia
nocoverlist_demopage, nocoverlist_cb, nocoverlist_assets = makedemos("theme_gallery/grid", nocoverlist_templates)
```
The page configuration file `nocoverlist/config.json` should contain an entry `theme = "nocoverlist"`, e.g.,
```json
{
"theme": "nocoverlist"
}
```
{{{democards}}}
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 104 | # Item1
## subsection 1
This is the first subsection
## subsection 2
This is the section subsection
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 876 | # Theme: Transition Grid
Given demos organized as following, you can make them displayed in grid-like manner. This is like
the [`"grid"` theme](@ref theme-grid) but uses a transition effect on the card covers.
```text
transitiongrid
βββ assets
βΒ Β βββ logo.svg
βββ config.json
βββ transitiongrid_section_1
βΒ Β βββ transitiongrid_subsection_1
βΒ Β βΒ Β βββ transitiongrid_card_1.md
βΒ Β βΒ Β βββ transitiongrid_card_2.md
βΒ Β βββ transitiongrid_subsection_2
βΒ Β βββ transitiongrid_card_3.md
βΒ Β βββ transitiongrid_card_4.md
βββ index.md
```
```julia
transitiongrid_demopage, transitiongrid_cb, transitiongrid_assets = makedemos("theme_gallery/transitiongrid", transitiongrid_templates)
```
The page configuration file `transitiongrid/config.json` should contain an entry `theme = "transitiongrid"`, e.g.,
```json
{
"theme": "transitiongrid"
}
```
{{{democards}}}
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 72 | ---
cover: ../../assets/logo.svg
description: some description here
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 101 | ---
author: "[Johnny Chen](https://github.com/johnnychen94); Jane Doe"
---
author with markdown url
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 65 | 
First valid image link is the cover
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 180 | 
<!--  -->

<!--  -->
First valid image link is the cover
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 60 | ---
cover: ../logo.png
---
Configure cover in front matter
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 96 | ---
cover: nonexistence.jpg
---

front matter overrides image link
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 134 | ---
title: Custom Title
description: >
this is a single line
destiption that spans
over multiple lines
---
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 133 | ---
title: Custom Title
description: |
this is a multi line
destiption that spans
over multiple lines
---
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 39 | # 1. Custom Title
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 57 | # [Custom Title 2](@id custom_id_2)
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 102 | # Custom Title 3-1
This is the content
# [Custom Title 3-2](@id custom_id_3-2)
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 49 | ---
title: Custom Title
---
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 81 | ---
title: Custom Title
description: Custom Description
---
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 161 | ---
title: Custom Title
id: custom_id
author: Jane Doe; John Roe
date: 2020-01-31
cover: https://juliaimages.org/latest/assets/logo.png
---
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 65 |
---
title: Custom Title
id: custom_id
---
This is the content
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 66 | ---
notebook: false
---
Markdown card never generates notebooks.
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 53 | ---
hidden: true
---
This is a hidden markdown card
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 79 | ---
hidden: false
---
This card is a normal card that shows in the page index
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 96 | # [Custom Title](@id custom_id)
This is the content of the template
---
{{{democards}}}
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 96 | # [Custom Title](@id custom_id)
This is the content of the template
---
{{{democards}}}
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 96 | # [Custom Title](@id custom_id)
This is the content of the template
---
{{{democards}}}
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 57 | ```julia
x, y = 1, 2
z = x + y
```

| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 41 | # This is a title
This is a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 58 | # [This is a title](@id custom_id)
This is a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 108 | # This is a title
This is a description
# [This is another title](@id custom_id)
This isn't a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 82 | # This is a title
# [This is another title](@id custom_id)
This is a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 115 | # This is a title
This is a description
that spreads along
multiple lines
# [This is another title](@id custom_id) | DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 126 | # This is a title
[This is a description](@ref custom_id)
# [This is another title](@id custom_id)
This isn't a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 83 | # This is a title
# [This is another title](@id custom_id)
This is a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 100 | # This is a title
```
x = 1+1
```
# [This is another title](@id custom_id)
This is a description
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 253 | ---
title: this has higher priority than [2]
description: this has higher priority than [1]
---
This is parsed as a description line --- [1]
# this is a section title --- [2]
but won't be recognized as a card title because it's put after the contents
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 610 | ```@meta
EditURL = "/tmp/jl_MynnRG/card/julia/title_7.jl"
```
# [Custom Title](@id custom_id)
[](title_7.jl)    
This is the content
---
*This page was generated using [DemoCards.jl](https://github.com/JuliaDocs/DemoCards.jl) and [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 401 | ```@meta
EditURL = "/tmp/jl_MynnRG/card/markdown/title_6.md"
```
# [Custom Title](@id custom_id)
  
This is the content
---
*This page was generated using [DemoCards.jl](https://github.com/JuliaDocs/DemoCards.jl).*
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 459 | ```@meta
EditURL = "/tmp/jl_MynnRG/preview/index.md"
```
# Preview
# Scripts
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Demo2
```@raw html
</div>
```
[](@ref Demo2)
```@raw html
</div>
<div class="grid-card-text">
```
[Demo2](@ref Demo2)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 518 | ```@meta
EditURL = "/tmp/jl_MynnRG/preview_page/index.md"
```
# Preview page
# Preview section
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Preview demo1
```@raw html
</div>
```
[](@ref Preview-demo1)
```@raw html
</div>
<div class="grid-card-text">
```
[Preview demo1](@ref Preview-demo1)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 482 | ```@meta
EditURL = "/tmp/jl_MynnRG/template/template.md"
```
# Template
# Subsection 2
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 3
```@raw html
</div>
```
[](@ref Card-3)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 3](@ref Card-3)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 1587 | ```@meta
EditURL = "/tmp/jl_MynnRG/template/template.md"
```
# [Custom Title](@id custom_id)
This is the content of the template
---
# Subsection 1
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 1
```@raw html
</div>
```
[](@ref Card-1)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 1](@ref Card-1)
```@raw html
</div>
</div>
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 2
```@raw html
</div>
```
[](@ref Card-2)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 2](@ref Card-2)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
# Subsection 2
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 3
```@raw html
</div>
```
[](@ref Card-3)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 3](@ref Card-3)
```@raw html
</div>
</div>
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 4
```@raw html
</div>
```
[](@ref Card-4)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 4](@ref Card-4)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
---
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 769 | ```@meta
EditURL = "/tmp/jl_MynnRG/preview/index.md"
```
# Preview
# Scripts
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Demo1
```@raw html
</div>
```
[](@ref Demo1)
```@raw html
</div>
<div class="grid-card-text">
```
[Demo1](@ref Demo1)
```@raw html
</div>
</div>
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Demo2
```@raw html
</div>
```
[](@ref Demo2)
```@raw html
</div>
<div class="grid-card-text">
```
[Demo2](@ref Demo2)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 0.5.5 | bb21a5a9b9f6234f367ba3d47d3b3098b3911788 | docs | 796 | ```@meta
EditURL = "/tmp/jl_MynnRG/template/template.md"
```
# Template
# Subsection 2
```@raw html
<div class="grid-card-section">
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 3
```@raw html
</div>
```
[](@ref Card-3)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 3](@ref Card-3)
```@raw html
</div>
</div>
```
```@raw html
<div class="card grid-card">
<div class="grid-card-cover">
<div class="grid-card-description">
```
Card 4
```@raw html
</div>
```
[](@ref Card-4)
```@raw html
</div>
<div class="grid-card-text">
```
[Card 4](@ref Card-4)
```@raw html
</div>
</div>
```
```@raw html
</div>
```
| DemoCards | https://github.com/JuliaDocs/DemoCards.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 736 | using LibAwsCompression
using Documenter
DocMeta.setdocmeta!(LibAwsCompression, :DocTestSetup, :(using LibAwsCompression); recursive=true)
makedocs(;
modules=[LibAwsCompression],
repo="https://github.com/JuliaServices/LibAwsCompression.jl/blob/{commit}{path}#{line}",
sitename="LibAwsCompression.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://github.com/JuliaServices/LibAwsCompression.jl",
assets=String[],
size_threshold=2_000_000, # 2 MB, we generate about 1 MB page
size_threshold_warn=2_000_000,
),
pages=["Home" => "index.md"],
)
deploydocs(; repo="github.com/JuliaServices/LibAwsCompression.jl", devbranch="main")
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 4040 | using Clang.Generators
using Clang.JLLEnvs
using JLLPrefixes
import aws_c_common_jll, aws_c_compression_jll
using LibAwsCommon
cd(@__DIR__)
const refs_to_remove = []
# This is called if the docs generated from the extract_c_comment_style method did not generate any lines.
# We need to generate at least some docs so that cross-references work with Documenter.jl.
function get_docs(node, docs)
# The macro node types (except for MacroDefault) seem to not generate code, but they will still emit docs and then
# you end up with docs stacked on top of each other, which is a Julia LoadError.
if node.type isa Generators.AbstractMacroNodeType && !(node.type isa Generators.MacroDefault)
return String[]
end
# don't generate empty docs because it makes Documenter.jl mad
if isempty(docs)
return ["Documentation not found."]
end
# remove references to things which don't exist because it causes Documenter.jl's cross_references check to fail
for ref in refs_to_remove
for doci in eachindex(docs)
docs[doci] = replace(docs[doci], "[`$ref`](@ref)" => "`$ref`")
end
end
# # fix other random stuff
# for doci in eachindex(docs)
# # fix some code that gets bogus references inserted
# docs[doci] = replace(docs[doci], "for (struct [`aws_hash_iter`](@ref) iter = [`aws_hash_iter_begin`](@ref)(&map); (&iter); [`aws_hash_iter_next`](@ref)(&iter)) { const key\\_type key = *(const key\\_type *)iter.element.key; value\\_type value = *(value\\_type *)iter.element.value; // etc. }" => "`for (struct aws_hash_iter iter = aws_hash_iter_begin(&map); !aws_hash_iter_done(&iter); aws_hash_iter_next(&iter)) { const key\\_type key = *(const key\\_type *)iter.element.key; value\\_type value = *(value\\_type *)iter.element.value; // etc. }`")
# end
return docs
end
function should_skip_target(target)
# aws_c_common_jll does not support i686 windows https://github.com/JuliaPackaging/Yggdrasil/blob/bbab3a916ae5543902b025a4a873cf9ee4a7de68/A/aws_c_common/build_tarballs.jl#L48-L49
return target == "i686-w64-mingw32"
end
const deps_jlls = [aws_c_common_jll]
const deps = [LibAwsCommon]
const deps_names = sort(collect(Iterators.flatten(names.(deps))))
# clang can emit code for forward declarations of structs defined in our dependencies. we need to skip those, otherwise
# we'll have duplicate struct definitions.
function skip_nodes_in_dependencies!(dag::ExprDAG)
replace!(get_nodes(dag)) do node
if insorted(node.id, deps_names)
return ExprNode(node.id, Generators.Skip(), node.cursor, Expr[], node.adj)
end
return node
end
end
# download toolchains in parallel
Threads.@threads for target in JLLEnvs.JLL_ENV_TRIPLES
if should_skip_target(target)
continue
end
get_default_args(target) # downloads the toolchain
end
for target in JLLEnvs.JLL_ENV_TRIPLES
if should_skip_target(target)
continue
end
options = load_options(joinpath(@__DIR__, "generator.toml"))
options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "lib", "$target.jl")
options["general"]["callback_documentation"] = get_docs
args = get_default_args(target)
for dep in deps_jlls
inc = JLLEnvs.get_pkg_include_dir(dep, target)
push!(args, "-isystem$inc")
end
header_dirs = []
inc = JLLEnvs.get_pkg_include_dir(aws_c_compression_jll, target)
push!(args, "-I$inc")
push!(header_dirs, inc)
headers = String[]
for header_dir in header_dirs
for (root, dirs, files) in walkdir(header_dir)
for file in files
if endswith(file, ".h")
push!(headers, joinpath(root, file))
end
end
end
end
unique!(headers)
ctx = create_context(headers, args, options)
build!(ctx, BUILDSTAGE_NO_PRINTING)
skip_nodes_in_dependencies!(ctx.dag)
build!(ctx, BUILDSTAGE_PRINTING_ONLY)
end
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 7188 | using CEnum
"""
aws_compression_error
Documentation not found.
"""
@cenum aws_compression_error::UInt32 begin
AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL = 3072
AWS_ERROR_END_COMPRESSION_RANGE = 4095
end
"""
aws_compression_library_init(alloc)
Initializes internal datastructures used by aws-c-compression. Must be called before using any functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_init(struct aws_allocator *alloc);
```
"""
function aws_compression_library_init(alloc)
ccall((:aws_compression_library_init, libaws_c_compression), Cvoid, (Ptr{Cvoid},), alloc)
end
"""
aws_compression_library_clean_up()
Clean up internal datastructures used by aws-c-compression. Must not be called until application is done using functionality in aws-c-compression.
### Prototype
```c
void aws_compression_library_clean_up(void);
```
"""
function aws_compression_library_clean_up()
ccall((:aws_compression_library_clean_up, libaws_c_compression), Cvoid, ())
end
"""
aws_huffman_code
Represents an encoded code
"""
struct aws_huffman_code
pattern::UInt32
num_bits::UInt8
end
# typedef struct aws_huffman_code ( aws_huffman_symbol_encoder_fn ) ( uint8_t symbol , void * userdata )
"""
Function used to encode a single symbol to an [`aws_huffman_code`](@ref)
# Arguments
* `symbol`:\\[in\\] The symbol to encode
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The code representing the symbol. If this symbol is not recognized, return a code with num\\_bits set to 0.
"""
const aws_huffman_symbol_encoder_fn = Cvoid
# typedef uint8_t ( aws_huffman_symbol_decoder_fn ) ( uint32_t bits , uint8_t * symbol , void * userdata )
"""
Function used to decode a code into a symbol
# Arguments
* `bits`:\\[in\\] The bits to attept to decode a symbol from
* `symbol`:\\[out\\] The symbol found. Do not write to if no valid symbol found
* `userdata`:\\[in\\] Optional userdata ([`aws_huffman_symbol_coder`](@ref).userdata)
# Returns
The number of bits read from bits
"""
const aws_huffman_symbol_decoder_fn = Cvoid
"""
aws_huffman_symbol_coder
Structure used to define how symbols are encoded and decoded
"""
struct aws_huffman_symbol_coder
encode::Ptr{aws_huffman_symbol_encoder_fn}
decode::Ptr{aws_huffman_symbol_decoder_fn}
userdata::Ptr{Cvoid}
end
"""
aws_huffman_encoder
Structure used for persistent encoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_encoder
coder::Ptr{aws_huffman_symbol_coder}
eos_padding::UInt8
overflow_bits::aws_huffman_code
end
"""
aws_huffman_decoder
Structure used for persistent decoding. Allows for reading from or writing to incomplete buffers.
"""
struct aws_huffman_decoder
coder::Ptr{aws_huffman_symbol_coder}
allow_growth::Bool
working_bits::UInt64
num_bits::UInt8
end
"""
aws_huffman_encoder_init(encoder, coder)
Initialize a encoder object with a symbol coder.
### Prototype
```c
void aws_huffman_encoder_init(struct aws_huffman_encoder *encoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_encoder_init(encoder, coder)
ccall((:aws_huffman_encoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder}, Ptr{aws_huffman_symbol_coder}), encoder, coder)
end
"""
aws_huffman_encoder_reset(encoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_encoder_reset(struct aws_huffman_encoder *encoder);
```
"""
function aws_huffman_encoder_reset(encoder)
ccall((:aws_huffman_encoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_encoder},), encoder)
end
"""
aws_huffman_decoder_init(decoder, coder)
Initialize a decoder object with a symbol coder.
### Prototype
```c
void aws_huffman_decoder_init(struct aws_huffman_decoder *decoder, struct aws_huffman_symbol_coder *coder);
```
"""
function aws_huffman_decoder_init(decoder, coder)
ccall((:aws_huffman_decoder_init, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Ptr{aws_huffman_symbol_coder}), decoder, coder)
end
"""
aws_huffman_decoder_reset(decoder)
Resets a decoder for use with a new binary stream
### Prototype
```c
void aws_huffman_decoder_reset(struct aws_huffman_decoder *decoder);
```
"""
function aws_huffman_decoder_reset(decoder)
ccall((:aws_huffman_decoder_reset, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder},), decoder)
end
"""
aws_huffman_get_encoded_length(encoder, to_encode)
Get the byte length of to\\_encode post-encoding.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
# Returns
The length of the encoded string.
### Prototype
```c
size_t aws_huffman_get_encoded_length(struct aws_huffman_encoder *encoder, struct aws_byte_cursor to_encode);
```
"""
function aws_huffman_get_encoded_length(encoder, to_encode)
ccall((:aws_huffman_get_encoded_length, libaws_c_compression), Csize_t, (Ptr{aws_huffman_encoder}, aws_byte_cursor), encoder, to_encode)
end
"""
aws_huffman_encode(encoder, to_encode, output)
Encode a symbol buffer into the output buffer.
# Arguments
* `encoder`:\\[in\\] The encoder object to use
* `to_encode`:\\[in\\] The symbol buffer to encode
* `output`:\\[in\\] The buffer to write encoded bytes to
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_encode( struct aws_huffman_encoder *encoder, struct aws_byte_cursor *to_encode, struct aws_byte_buf *output);
```
"""
function aws_huffman_encode(encoder, to_encode, output)
ccall((:aws_huffman_encode, libaws_c_compression), Cint, (Ptr{aws_huffman_encoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), encoder, to_encode, output)
end
"""
aws_huffman_decode(decoder, to_decode, output)
Decodes a byte buffer into the provided symbol array.
# Arguments
* `decoder`:\\[in\\] The decoder object to use
* `to_decode`:\\[in\\] The encoded byte buffer to read from
* `output`:\\[in\\] The buffer to write decoded symbols to. If decoder is set to allow growth, capacity will be increased when necessary.
# Returns
AWS\\_OP\\_SUCCESS if encoding is successful, AWS\\_OP\\_ERR otherwise
### Prototype
```c
int aws_huffman_decode( struct aws_huffman_decoder *decoder, struct aws_byte_cursor *to_decode, struct aws_byte_buf *output);
```
"""
function aws_huffman_decode(decoder, to_decode, output)
ccall((:aws_huffman_decode, libaws_c_compression), Cint, (Ptr{aws_huffman_decoder}, Ptr{aws_byte_cursor}, Ptr{Cvoid}), decoder, to_decode, output)
end
"""
aws_huffman_decoder_allow_growth(decoder, allow_growth)
Set whether or not to increase capacity when the output buffer fills up while decoding. This is false by default.
### Prototype
```c
void aws_huffman_decoder_allow_growth(struct aws_huffman_decoder *decoder, bool allow_growth);
```
"""
function aws_huffman_decoder_allow_growth(decoder, allow_growth)
ccall((:aws_huffman_decoder_allow_growth, libaws_c_compression), Cvoid, (Ptr{aws_huffman_decoder}, Bool), decoder, allow_growth)
end
"""
Documentation not found.
"""
const AWS_C_COMPRESSION_PACKAGE_ID = 3
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 2081 | module LibAwsCompression
using aws_c_compression_jll
using LibAwsCommon
const IS_LIBC_MUSL = occursin("musl", Base.BUILD_TRIPLET)
if Sys.isapple() && Sys.ARCH === :aarch64
include("../lib/aarch64-apple-darwin20.jl")
elseif Sys.islinux() && Sys.ARCH === :aarch64 && !IS_LIBC_MUSL
include("../lib/aarch64-linux-gnu.jl")
elseif Sys.islinux() && Sys.ARCH === :aarch64 && IS_LIBC_MUSL
include("../lib/aarch64-linux-musl.jl")
elseif Sys.islinux() && startswith(string(Sys.ARCH), "arm") && !IS_LIBC_MUSL
include("../lib/armv7l-linux-gnueabihf.jl")
elseif Sys.islinux() && startswith(string(Sys.ARCH), "arm") && IS_LIBC_MUSL
include("../lib/armv7l-linux-musleabihf.jl")
elseif Sys.islinux() && Sys.ARCH === :i686 && !IS_LIBC_MUSL
include("../lib/i686-linux-gnu.jl")
elseif Sys.islinux() && Sys.ARCH === :i686 && IS_LIBC_MUSL
include("../lib/i686-linux-musl.jl")
elseif Sys.iswindows() && Sys.ARCH === :i686
error("LibAwsCommon.jl does not support i686 windows https://github.com/JuliaPackaging/Yggdrasil/blob/bbab3a916ae5543902b025a4a873cf9ee4a7de68/A/aws_c_common/build_tarballs.jl#L48-L49")
elseif Sys.islinux() && Sys.ARCH === :powerpc64le
include("../lib/powerpc64le-linux-gnu.jl")
elseif Sys.isapple() && Sys.ARCH === :x86_64
include("../lib/x86_64-apple-darwin14.jl")
elseif Sys.islinux() && Sys.ARCH === :x86_64 && !IS_LIBC_MUSL
include("../lib/x86_64-linux-gnu.jl")
elseif Sys.islinux() && Sys.ARCH === :x86_64 && IS_LIBC_MUSL
include("../lib/x86_64-linux-musl.jl")
elseif Sys.isbsd() && !Sys.isapple()
include("../lib/x86_64-unknown-freebsd13.2.jl")
elseif Sys.iswindows() && Sys.ARCH === :x86_64
include("../lib/x86_64-w64-mingw32.jl")
else
error("Unknown platform: $(Base.BUILD_TRIPLET)")
end
# exports
for name in names(@__MODULE__; all=true)
if name == :eval || name == :include || contains(string(name), "#")
continue
end
@eval export $name
end
function init(allocator=default_aws_allocator())
LibAwsCommon.init(allocator)
aws_compression_library_init(allocator)
return
end
end
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | code | 505 | using Test, Aqua, LibAwsCompression, LibAwsCommon
@testset "LibAwsCompression" begin
@testset "aqua" begin
Aqua.test_all(LibAwsCompression, ambiguities=false)
Aqua.test_ambiguities(LibAwsCompression)
end
@testset "basic usage to test the library loads" begin
alloc = aws_default_allocator() # important! this shouldn't need to be qualified! if we generate a definition for it in LibAwsCompression that is a bug.
aws_compression_library_init(alloc)
end
end
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | docs | 531 | [](https://JuliaServices.github.io/LibAwsCompression.jl/stable)
[](https://JuliaServices.github.io/LibAwsCompression.jl/dev)
[](https://github.com/JuliaServices/LibAwsCompression.jl/actions/workflows/ci.yml)
# LibAwsCompression.jl
Julia bindings for the [aws-c-compression](https://github.com/awslabs/aws-c-compression) library.
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 1.1.0 | 54ba2d3fe231427104c3947d485ffd7396c14488 | docs | 226 | ```@meta
CurrentModule = LibAwsCompression
```
# LibAwsCompression
Documentation for [LibAwsCompression](https://github.com/JuliaServices/LibAwsCompression.jl).
```@index
```
```@autodocs
Modules = [LibAwsCompression]
```
| LibAwsCompression | https://github.com/JuliaServices/LibAwsCompression.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 194 | clima_formatter_options = (
indent = 4,
margin = 80,
always_for_in = true,
whitespace_typedefs = true,
whitespace_ops_in_indices = true,
remove_extra_newlines = false,
)
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 2585 | #!/usr/bin/env julia
#
# This is an adapted version of format.jl from JuliaFormatter with the
# following license:
#
# MIT License
# Copyright (c) 2019 Dominique Luna
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the
# following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
#
using Pkg
Pkg.activate(@__DIR__)
Pkg.instantiate()
using JuliaFormatter
include("clima_formatter_options.jl")
help = """
Usage: climaformat.jl [flags] [FILE/PATH]...
Formats the given julia files using the CLIMA formatting options. If paths
are given it will format the julia files in the paths. Otherwise, it will
format all changed julia files.
-v, --verbose
Print the name of the files being formatted with relevant details.
-h, --help
Print this message.
"""
function parse_opts!(args::Vector{String})
i = 1
opts = Dict{Symbol, Union{Int, Bool}}()
while i β€ length(args)
arg = args[i]
if arg[1] != '-'
i += 1
continue
end
if arg == "-v" || arg == "--verbose"
opt = :verbose
elseif arg == "-h" || arg == "--help"
opt = :help
else
error("invalid option $arg")
end
if opt in (:verbose, :help)
opts[opt] = true
deleteat!(args, i)
end
end
return opts
end
opts = parse_opts!(ARGS)
if haskey(opts, :help)
write(stdout, help)
exit(0)
end
if isempty(ARGS)
filenames = readlines(`git ls-files "*.jl"`)
else
filenames = ARGS
end
format(filenames; clima_formatter_options..., opts...)
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1508 | module MultiBroadcastFusionCUDAExt
import CUDA, Adapt
import MultiBroadcastFusion as MBF
import MultiBroadcastFusion: fused_copyto!
MBF.device(x::CUDA.CuArray) = MBF.GPU()
function fused_copyto!(fmb::MBF.FusedMultiBroadcast, ::MBF.GPU)
(; pairs) = fmb
dest = first(pairs).first
nitems = length(parent(dest))
max_threads = 256 # can be higher if conditions permit
nthreads = min(max_threads, nitems)
nblocks = cld(nitems, nthreads)
CUDA.@cuda threads = (nthreads) blocks = (nblocks) fused_copyto_kernel!(fmb)
return nothing
end
function fused_copyto_kernel!(fmb::MBF.FusedMultiBroadcast)
(; pairs) = fmb
dest = first(pairs).first
nitems = length(dest)
idx = CUDA.threadIdx().x + (CUDA.blockIdx().x - 1) * CUDA.blockDim().x
if idx β€ nitems
MBF.rcopyto_at!(pairs, idx)
end
return nothing
end
adapt_f(to, f::F) where {F} = Adapt.adapt(to, f)
adapt_f(to, ::Type{F}) where {F} = (x...) -> F(x...)
adapt_src(to, src::AbstractArray) = Adapt.adapt(to, src)
function adapt_src(to, bc::Base.Broadcast.Broadcasted)
Base.Broadcast.Broadcasted(
bc.style,
adapt_f(to, bc.f),
Adapt.adapt(to, bc.args),
Adapt.adapt(to, bc.axes),
)
end
function Adapt.adapt_structure(
to::CUDA.KernelAdaptor,
fmbc::MBF.FusedMultiBroadcast,
)
MBF.FusedMultiBroadcast(map(fmbc.pairs) do pair
dest = pair.first
src = pair.second
Pair(Adapt.adapt(to, dest), adapt_src(to, src))
end)
end
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1157 | #=
using Revise; include(joinpath("perf", "flame.jl"))
=#
import MultiBroadcastFusion as MBF
include(joinpath(pkgdir(MBF), "test", "execution", "utils.jl"))
# ===========================================
has_cuda = CUDA.has_cuda()
AType = has_cuda ? CUDA.CuArray : Array
# arr_size = (prod((50,5,5,6,50)),)
arr_size = (50, 5, 5, 6, 50)
X = get_arrays(:x, arr_size, AType)
Y = get_arrays(:y, arr_size, AType)
function perf_kernel_fused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
@fused_direct begin
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
@. y3 = x3 + x4 + x5 + x6
@. y4 = x4 + x5 + x6 + x7
@. y5 = x5 + x6 + x7 + x8
@. y6 = x6 + x7 + x8 + x9
@. y7 = x7 + x8 + x9 + x10
end
end
import Profile, ProfileCanvas
function do_work!(X, Y, N)
for i in 1:N
perf_kernel_fused!(X, Y)
end
end
do_work!(X, Y, 1) # compile
@info "collect profile"
Profile.clear()
prof = Profile.@profile do_work!(X, Y, 100)
results = Profile.fetch()
Profile.clear()
ProfileCanvas.html_file(joinpath("flame.html"), results)
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 378 | module MultiBroadcastFusion
include(joinpath("collection", "utils.jl"))
include(joinpath("collection", "macros.jl"))
include(joinpath("collection", "code_lowered_single_expression.jl"))
include(joinpath("collection", "fused_direct.jl"))
include(joinpath("collection", "fused_assemble.jl"))
include(joinpath("execution", "fused_kernels.jl"))
end # module MultiBroadcastFusion
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 596 | # General case: do nothing (identity)
substitute(x, code) = x
substitute(x::Core.SSAValue, code) = substitute(code[x.id], code)
substitute(x::Core.ReturnNode, code) = substitute(code[x.val.id], code)
substitute(s::Symbol, code) = s
# Expression: recursively substitute for Expr
substitute(e::Expr, code) =
Expr(substitute(e.head, code), substitute.(e.args, Ref(code))...)
code_info(expr) = Base.Meta.lower(Main, expr).args[1]
function code_lowered_single_expression(expr)
code = code_info(expr).code # vector
s = string(substitute(code[end], code))
return Base.Meta.parse(s)
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 3296 | #####
##### Fused assemble
#####
# General case: do nothing (identity)
transform_assemble(x, sym) = x
transform_assemble(s::Symbol, sym) = s
# Expression: recursively transform_assemble for Expr
function transform_assemble(e::Expr, sym)
if e.head == :macrocall && e.args[1] == Symbol("@__dot__")
se = code_lowered_single_expression(e)
margs = materialize_args(se)
subexpr = :($sym = ($sym..., Pair($(margs[1]), $(margs[2]))))
subexpr
else
Expr(
transform_assemble(e.head, sym),
transform_assemble.(e.args, sym)...,
)
end
end
"""
fused_assemble(expr::Expr)
Transforms the input expressions
into a runtime assembly of a tuple
of `Pair`s, containing (firsts)
the destination of broadcast expressions
and (seconds) the broadcasted objects.
For example:
```julia
import MultiBroadcastFusion as MBF
using Test
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
expr_out = quote
tup = ()
tup = (tup..., Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)))
tup = (tup..., Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)))
tup
end
@test MBF.linefilter!(MBF.fused_assemble(expr_in, :tup)) ==
MBF.linefilter!(expr_out)
@test MBF.fused_assemble(expr_in, :tup) == expr_out
```
This can be used to make a custom kernel fusion macro:
```
import MultiBroadcastFusion as MBF
import MultiBroadcastFusion: fused_assemble
MBF.@make_type MyFusedBroadcast
MBF.@make_fused fused_assemble MyFusedBroadcast my_fused
Base.copyto!(fmb::MyFusedBroadcast) = println("You're ready to fuse!")
x1 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 4 reads, 2 writes
@my_fused begin
for i in 1:3
@. y1 = x1
@. y2 = x1
end
end
```
Also see [`fused_direct`](@ref)
"""
fused_assemble(expr::Expr) = fused_assemble(expr, gensym())
function fused_assemble(expr::Expr, sym::Symbol)
check_restrictions_assemble(expr)
e = transform_assemble(expr, sym)
@assert e.head == :block
ex = Expr(:block, :($sym = ()), e.args..., sym)
# Filter out LineNumberNode, as this will not be valid due to prepending `tup = ()`
linefilter!(ex)
ex
end
function check_restrictions_assemble(expr::Expr)
for arg in expr.args
arg isa LineNumberNode && continue
s_error = if arg isa QuoteNode
"Dangling symbols are not allowed inside fused blocks"
elseif arg.head == :call
"Function calls are not allowed inside fused blocks"
elseif arg.head == :(=)
"Non-broadcast assignments are not allowed inside fused blocks"
elseif arg.head == :let
"Let-blocks are not allowed inside fused blocks"
elseif arg.head == :quote
"Quotes are not allowed inside fused blocks"
else
""
end
isempty(s_error) || error(s_error)
if arg.head == :macrocall && arg.args[1] == Symbol("@__dot__")
elseif arg.head == :for
check_restrictions(arg.args[2])
elseif arg.head == :if
check_restrictions(arg.args[2])
elseif arg.head == :macrocall && arg.args[1] == Symbol("@inbounds")
else
@show dump(arg)
error("Uncaught edge case")
end
end
return nothing
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 2800 | #####
##### Simple version
#####
# General case: do nothing (identity)
transform(x) = x
transform(s::Symbol) = s
# Expression: recursively transform for Expr
function transform(e::Expr)
if e.head == :macrocall && e.args[1] == Symbol("@__dot__")
se = code_lowered_single_expression(e)
margs = materialize_args(se)
subexpr = :(Pair($(margs[1]), $(margs[2])))
subexpr
else
Expr(transform(e.head), transform.(e.args)...)
end
end
"""
fused_direct(expr::Expr)
Directly transforms the input expression
into a tuple of `Pair`s, containing (firsts)
the destination of broadcast expressions and
(seconds) the broadcasted objects.
For example:
```julia
import MultiBroadcastFusion as MBF
using Test
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
expr_out = :(tuple(
Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)),
Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)),
))
@test MBF.fused_direct(expr_in) == expr_out
```
This can be used to make a custom kernel fusion macro:
```
import MultiBroadcastFusion as MBF
import MultiBroadcastFusion: fused_direct
MBF.@make_type MyFusedBroadcast
MBF.@make_fused fused_direct MyFusedBroadcast my_fused
Base.copyto!(fmb::MyFusedBroadcast) = println("You're ready to fuse!")
x1 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 4 reads, 2 writes
@my_fused begin
@. y1 = x1
@. y2 = x1
end
```
Also see [`fused_assemble`](@ref)
"""
function fused_direct(expr::Expr)
check_restrictions(expr)
e = transform(expr)
@assert e.head == :block
ex = Expr(:call, :tuple, e.args...)
# Filter out LineNumberNode, as this will not be valid due to prepending `tup = ()`
linefilter!(ex)
ex
end
function check_restrictions(expr::Expr)
for _expr in expr.args
_expr isa LineNumberNode && continue
s_error = if _expr isa QuoteNode
"Dangling symbols are not allowed inside fused blocks"
elseif _expr.head == :for
"Loops are not allowed inside fused blocks"
elseif _expr.head == :if
"If-statements are not allowed inside fused blocks"
elseif _expr.head == :call
"Function calls are not allowed inside fused blocks"
elseif _expr.head == :(=)
"Non-broadcast assignments are not allowed inside fused blocks"
elseif _expr.head == :let
"Let-blocks are not allowed inside fused blocks"
elseif _expr.head == :quote
"Quotes are not allowed inside fused blocks"
else
""
end
isempty(s_error) || error(s_error)
if _expr.head == :macrocall && _expr.args[1] == Symbol("@__dot__")
else
@show dump(_expr)
error("Uncaught edge case")
end
end
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1154 | """
@make_type type_name
This macro defines a type `type_name`, to be
passed to `@make_fused`.
"""
macro make_type(type_name)
t = esc(type_name)
return quote
struct $t{T <: Union{Tuple, AbstractArray}}
pairs::T
end
end
end
"""
@make_fused fusion_style type_name fused_named
This macro
- Defines a type type_name
- Defines a macro, `@fused_name`, using the fusion type `fusion_style`
This allows users to flexibility
to customize their broadcast fusion.
# Example
```julia
import MultiBroadcastFusion as MBF
MBF.@make_type MyFusedBroadcast
MBF.@make_fused MBF.fused_direct MyFusedBroadcast my_fused
Base.copyto!(fmb::MyFusedBroadcast) = println("You're ready to fuse!")
x1 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 4 reads, 2 writes
@my_fused begin
@. y1 = x1
@. y2 = x1
end
```
"""
macro make_fused(fusion_style, type_name, fused_name)
t = esc(type_name)
f = esc(fused_name)
return quote
macro $f(expr)
_pairs = esc($(fusion_style)(expr))
t = $t
quote
Base.copyto!($t($_pairs))
end
end
end
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 919 | #####
##### Helper
#####
# Recursively remove LineNumberNode from an `Expr`
@noinline function linefilter!(expr::Expr)
total = length(expr.args)
i = 0
while i < total
i += 1
if expr.args[i] |> typeof == Expr
if expr.args[i].head == :line
deleteat!(expr.args, i)
total -= 1
i -= 1
else
expr.args[i] = linefilter!(expr.args[i])
end
elseif expr.args[i] |> typeof == LineNumberNode
if expr.head == :macrocall
expr.args[i] = nothing
else
deleteat!(expr.args, i)
total -= 1
i -= 1
end
end
end
return expr
end
function materialize_args(expr::Expr)
@assert expr.head == :call
@assert expr.args[1] == :(Base.materialize!)
return (expr.args[2], expr.args[3])
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1756 | @make_type FusedMultiBroadcast
@make_fused fused_direct FusedMultiBroadcast fused_direct
@make_fused fused_assemble FusedMultiBroadcast fused_assemble
struct CPU end
struct GPU end
device(x::AbstractArray) = CPU()
function Base.copyto!(fmb::FusedMultiBroadcast)
pairs = fmb.pairs # (Pair(dest1, bc1),Pair(dest2, bc2),...)
dest = first(pairs).first
fused_copyto!(fmb, device(dest))
end
Base.@propagate_inbounds function rcopyto_at!(pair::Pair, i...)
dest, src = pair.first, pair.second
@inbounds dest[i...] = src[i...]
return nothing
end
Base.@propagate_inbounds function rcopyto_at!(pairs::Tuple, i...)
rcopyto_at!(first(pairs), i...)
rcopyto_at!(Base.tail(pairs), i...)
end
Base.@propagate_inbounds rcopyto_at!(pairs::Tuple{<:Any}, i...) =
rcopyto_at!(first(pairs), i...)
@inline rcopyto_at!(pairs::Tuple{}, i...) = nothing
# This is better than the baseline.
function fused_copyto!(fmb::FusedMultiBroadcast, ::CPU)
(; pairs) = fmb
destinations = map(x -> x.first, pairs)
ei = if eltype(destinations) <: Vector
eachindex(destinations...)
else
eachindex(IndexCartesian(), destinations...)
end
for (dest, bc) in pairs
@inbounds @simd ivdep for i in ei
dest[i] = bc[i]
end
end
end
# This should, in theory be better, but it seems like inlining is
# failing somewhere.
# function fused_copyto!(fmb::FusedMultiBroadcast, ::CPU)
# (; pairs) = fmb
# destinations = map(x -> x.first, pairs)
# ei = if eltype(destinations) <: Vector
# eachindex(destinations...)
# else
# eachindex(IndexCartesian(), destinations...)
# end
# @inbounds @simd ivdep for i in ei
# MBF.rcopyto_at!(pairs, i)
# end
# end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 292 | #=
using Revise; include(joinpath("test", "collection", "runtests.jl"))
using Revise; include(joinpath("test", "execution", "runtests.jl"))
using Revise; include(joinpath("test", "runtests.jl"))
=#
include(joinpath("collection", "runtests.jl"))
include(joinpath("execution", "runtests.jl"))
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1569 | #=
using Revise; include(joinpath("test", "collection", "expr_code_lowered_single_expression.jl"))
=#
using Test
import MultiBroadcastFusion as MBF
@testset "code_lowered_single_expression" begin
expr_in = :(@. y1 = x1 + x2 + x3 + x4)
expr_out = :(Base.materialize!(y1, Base.broadcasted(+, x1, x2, x3, x4)))
@test MBF.code_lowered_single_expression(expr_in) == expr_out
end
@testset "code_lowered_single_expression - examples from the wild" begin
expr_in = quote
@. αΆcloud_fraction = quad_loop(
SG_quad,
αΆts,
Geometry.WVector(p.precomputed.αΆgradα΅₯_q_tot),
Geometry.WVector(p.precomputed.αΆgradα΅₯_ΞΈ_liq_ice),
coeff,
αΆmixing_length,
thermo_params,
)
end
expr_out = :(Base.materialize!(
αΆcloud_fraction,
Base.broadcasted(
quad_loop,
SG_quad,
αΆts,
Base.broadcasted(
Base.getproperty(Geometry, :WVector),
Base.getproperty(
Base.getproperty(p, :precomputed),
:αΆgradα΅₯_q_tot,
),
),
Base.broadcasted(
Base.getproperty(Geometry, :WVector),
Base.getproperty(
Base.getproperty(p, :precomputed),
:αΆgradα΅₯_ΞΈ_liq_ice,
),
),
coeff,
αΆmixing_length,
thermo_params,
),
))
@test MBF.code_lowered_single_expression(expr_in) == expr_out
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 3722 | #=
using Revise; include(joinpath("test", "collection" "expr_errors_and_edge_cases.jl"))
=#
using Test
import MultiBroadcastFusion as MBF
@testset "loops" begin
# loops are not allowed, because
# code transformation occurs at macro
# expansion time, and we can't generally
# know how many times the loop will be
# executed at this time.
# We could try to specialize on literal ranges, e.g.,
# `for i in 1:10`, but that is likely an uncommon
# edge case.
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
for i in 1:10
@. y2 = x2 + x3 + x4 + x5
end
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException("Loops are not allowed inside fused blocks") MBF.fused_direct(
expr_in,
)
end
struct Foo end
@testset "If-statements" begin
# If-statements are not allowed, because
# code transformation occurs at macro
# expansion time, and Bools, even types,
# are not known at this time.
# We could specialize on literals, e.g.,
# `if true`, but that is likely an uncommon
# edge case.
foo = Foo()
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
if foo isa Foo
@. y2 = x2 + x3 + x4 + x5
end
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException(
"If-statements are not allowed inside fused blocks",
) MBF.fused_direct(expr_in)
end
bar() = nothing
@testset "Function calls" begin
# Function calls are not allowed, because
# this could lead to subtle bugs (order of compute).
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
bar()
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException(
"Function calls are not allowed inside fused blocks",
) MBF.fused_direct(expr_in)
end
@testset "Non-broadcast variable assignments" begin
# Non-broadcast variable assignments is not allowed, because
# this could lead to subtle bugs (order of compute).
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
x1 = x2
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException(
"Non-broadcast assignments are not allowed inside fused blocks",
) MBF.fused_direct(expr_in)
end
@testset "No let-blocks" begin
# Let-blocks could hide other non-allowed things
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
let z = 1
end
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException(
"Let-blocks are not allowed inside fused blocks",
) MBF.fused_direct(expr_in)
end
@testset "Dangling symbols" begin
# While inaucuous, we prohibit dangling symbols
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
:a
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException(
"Dangling symbols are not allowed inside fused blocks",
) MBF.fused_direct(expr_in)
end
@testset "quote" begin
# Not sure why this would be needed, so
# we don't allow quotes inside fused blocks.
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
quote end
@. y1 = x1 + x2 + x3 + x4
end
@test_throws ErrorException("Quotes are not allowed inside fused blocks") MBF.fused_direct(
expr_in,
)
end
@testset "Comments" begin
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
# Foo bar baz
# if i in 1:N
@. y2 = x2 + x3 + x4 + x5
end
expr_out = :(tuple(
Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)),
Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)),
))
@test MBF.fused_direct(expr_in) == expr_out
end
@testset "Empty" begin
expr_in = quote end
@test MBF.fused_direct(expr_in) == :(tuple())
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 2449 | #=
using Revise; include(joinpath("test", "collection", "expr_fused_assemble.jl"))
=#
using Test
import MultiBroadcastFusion as MBF
@testset "fused_assemble - simple sequential" begin
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
expr_out = quote
tup = ()
tup = (tup..., Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)))
tup = (tup..., Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)))
tup
end
@test MBF.linefilter!(MBF.fused_assemble(expr_in, :tup)) ==
MBF.linefilter!(expr_out)
@test MBF.fused_assemble(expr_in, :tup) == expr_out
end
@testset "fused_assemble - loop" begin
expr_in = quote
for i in 1:10
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
end
expr_out = quote
tup = ()
for i in 1:10
tup = (tup..., Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)))
tup = (tup..., Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)))
end
tup
end
@test MBF.linefilter!(MBF.fused_assemble(expr_in, :tup)) ==
MBF.linefilter!(expr_out)
@test MBF.fused_assemble(expr_in, :tup) == expr_out
end
@testset "fused_assemble - loop with @inbounds" begin
expr_in = quote
@inbounds for i in 1:10
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
end
expr_out = quote
tup = ()
@inbounds for i in 1:10
tup = (tup..., Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)))
tup = (tup..., Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)))
end
tup
end
@test MBF.linefilter!(MBF.fused_assemble(expr_in, :tup)) ==
MBF.linefilter!(expr_out)
@test MBF.fused_assemble(expr_in, :tup) == expr_out
end
@testset "fused_assemble - if" begin
expr_in = quote
if a && B || something(x, y, z)
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
end
expr_out = quote
tup = ()
if a && B || something(x, y, z)
tup = (tup..., Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)))
tup = (tup..., Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)))
end
tup
end
@test MBF.linefilter!(MBF.fused_assemble(expr_in, :tup)) ==
MBF.linefilter!(expr_out)
@test MBF.fused_assemble(expr_in, :tup) == expr_out
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 451 | #=
using Revise; include(joinpath("test", "collection", "expr_fused_direct.jl"))
=#
using Test
import MultiBroadcastFusion as MBF
@testset "fused_direct" begin
expr_in = quote
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
end
expr_out = :(tuple(
Pair(y1, Base.broadcasted(+, x1, x2, x3, x4)),
Pair(y2, Base.broadcasted(+, x2, x3, x4, x5)),
))
@test MBF.fused_direct(expr_in) == expr_out
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 366 | #=
using Revise; include(joinpath("test", "collection", "expr_materialize_args.jl"))
=#
using Test
import MultiBroadcastFusion as MBF
@testset "materialize_args" begin
expr_in = :(Base.materialize!(y1, Base.broadcasted(+, x1, x2, x3, x4)))
tuple_out = (:(y1), :(Base.broadcasted(+, x1, x2, x3, x4)))
@test MBF.materialize_args(expr_in) == tuple_out
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 616 | #=
using Revise; include(joinpath("test", "collection", "runtests.jl"))
=#
using Test
using SafeTestsets
#! format: off
@safetestset "expr_code_lowered_single_expression" begin; @time include("expr_code_lowered_single_expression.jl"); end
@safetestset "expr_materialize_args" begin; @time include("expr_materialize_args.jl"); end
@safetestset "expr_fused_direct" begin; @time include("expr_fused_direct.jl"); end
@safetestset "expr_fused_assemble" begin; @time include("expr_fused_assemble.jl"); end
@safetestset "expr_errors_and_edge_cases" begin; @time include("expr_errors_and_edge_cases.jl"); end
#! format: on
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 3516 | #=
using Revise; include(joinpath("test", "execution", "bm_fused_reads_vs_hard_coded.jl"))
=#
include("utils.jl")
# =========================================== hard-coded implementations
perf_kernel_hard_coded!(X, Y) = perf_kernel_hard_coded!(X, Y, MBF.device(X.x1))
function perf_kernel_hard_coded!(X, Y, ::MBF.CPU)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
@inbounds for i in eachindex(x1)
y1[i] = x1[i] + x2[i] + x3[i] + x4[i]
y2[i] = x2[i] + x3[i] + x4[i] + x5[i]
y3[i] = x3[i] + x4[i] + x5[i] + x6[i]
y4[i] = x4[i] + x5[i] + x6[i] + x7[i]
y5[i] = x5[i] + x6[i] + x7[i] + x8[i]
y6[i] = x6[i] + x7[i] + x8[i] + x9[i]
y7[i] = x7[i] + x8[i] + x9[i] + x10[i]
end
end
function perf_kernel_hard_coded!(X, Y, ::MBF.GPU)
x1 = X.x1
nitems = length(parent(x1))
max_threads = 256 # can be higher if conditions permit
nthreads = min(max_threads, nitems)
nblocks = cld(nitems, nthreads)
CUDA.@cuda threads = (nthreads) blocks = (nblocks) knl_multi_copyto_hard_coded!(
X,
Y,
Val(nitems),
)
end
function knl_multi_copyto_hard_coded!(X, Y, ::Val{nitems}) where {nitems}
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
idx = CUDA.threadIdx().x + (CUDA.blockIdx().x - 1) * CUDA.blockDim().x
@inbounds begin
if idx β€ nitems
y1[idx] = x1[idx] + x2[idx] + x3[idx] + x4[idx]
y2[idx] = x2[idx] + x3[idx] + x4[idx] + x5[idx]
y3[idx] = x3[idx] + x4[idx] + x5[idx] + x6[idx]
y4[idx] = x4[idx] + x5[idx] + x6[idx] + x7[idx]
y5[idx] = x5[idx] + x6[idx] + x7[idx] + x8[idx]
y6[idx] = x6[idx] + x7[idx] + x8[idx] + x9[idx]
y7[idx] = x7[idx] + x8[idx] + x9[idx] + x10[idx]
end
end
return nothing
end
# ===========================================
has_cuda = CUDA.has_cuda()
AType = has_cuda ? CUDA.CuArray : Array
arr_size = (prod((50, 5, 5, 6, 50)),)
# arr_size = (50,5,5,6,50)
X = get_arrays(:x, arr_size, AType);
Y = get_arrays(:y, arr_size, AType);
function perf_kernel_unfused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
# 7 writes; 10 unique reads
# 7 writes; 28 reads including redundant ones
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
@. y3 = x3 + x4 + x5 + x6
@. y4 = x4 + x5 + x6 + x7
@. y5 = x5 + x6 + x7 + x8
@. y6 = x6 + x7 + x8 + x9
@. y7 = x7 + x8 + x9 + x10
return nothing
end
function perf_kernel_fused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
MBF.@fused_direct begin
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
@. y3 = x3 + x4 + x5 + x6
@. y4 = x4 + x5 + x6 + x7
@. y5 = x5 + x6 + x7 + x8
@. y6 = x6 + x7 + x8 + x9
@. y7 = x7 + x8 + x9 + x10
end
end
test_kernel!(;
fused! = perf_kernel_fused!,
unfused! = perf_kernel_unfused!,
X,
Y,
)
test_kernel!(;
fused! = perf_kernel_hard_coded!,
unfused! = perf_kernel_unfused!,
X,
Y,
)
# Compile
perf_kernel_unfused!(X, Y)
perf_kernel_fused!(X, Y)
perf_kernel_hard_coded!(X, Y)
# Benchmark
benchmark_kernel!(perf_kernel_unfused!, X, Y)
benchmark_kernel!(perf_kernel_fused!, X, Y)
benchmark_kernel!(perf_kernel_hard_coded!, X, Y)
nothing
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1440 | #=
using Revise; include(joinpath("test", "execution", "bm_fused_shared_reads.jl"))
=#
include("utils.jl")
function perf_kernel_shared_reads_unfused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
@. y3 = x3 + x4 + x5 + x6
@. y4 = x4 + x5 + x6 + x7
@. y5 = x5 + x6 + x7 + x8
@. y6 = x6 + x7 + x8 + x9
@. y7 = x7 + x8 + x9 + x10
end
function perf_kernel_shared_reads_fused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
MBF.@fused_direct begin
@. y1 = x1 + x2 + x3 + x4
@. y2 = x2 + x3 + x4 + x5
@. y3 = x3 + x4 + x5 + x6
@. y4 = x4 + x5 + x6 + x7
@. y5 = x5 + x6 + x7 + x8
@. y6 = x6 + x7 + x8 + x9
@. y7 = x7 + x8 + x9 + x10
end
end
has_cuda = CUDA.has_cuda()
AType = has_cuda ? CUDA.CuArray : Array
arr_size = (prod((50, 5, 5, 6, 50)),)
X = get_arrays(:x, arr_size, AType)
Y = get_arrays(:y, arr_size, AType)
test_kernel!(;
fused! = perf_kernel_shared_reads_fused!,
unfused! = perf_kernel_shared_reads_unfused!,
X,
Y,
)
# Compile
perf_kernel_shared_reads_unfused!(X, Y)
perf_kernel_shared_reads_fused!(X, Y)
# Benchmark
benchmark_kernel!(perf_kernel_shared_reads_unfused!, X, Y)
benchmark_kernel!(perf_kernel_shared_reads_fused!, X, Y)
nothing
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 1498 | #=
using Revise; include(joinpath("test", "execution", "fused_reads_writes.jl"))
=#
include("utils.jl")
function perf_kernel_shared_reads_writes_unfused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
# Totoal: 10 writes, 15 reads, and 5 read/write overlaps
@. y1 = x1 + x6
@. y2 = x2 + x7
@. y3 = x3 + x8
@. y4 = x4 + x9
@. y5 = x5 + x10
@. y6 = y1
@. y7 = y2
@. y8 = y3
@. y9 = y4
@. y10 = y5
end
function perf_kernel_shared_reads_writes_fused!(X, Y)
(; x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = X
(; y1, y2, y3, y4, y5, y6, y7, y8, y9, y10) = Y
MBF.@fused_direct begin
@. y1 = x1 + x6
@. y2 = x2 + x7
@. y3 = x3 + x8
@. y4 = x4 + x9
@. y5 = x5 + x10
@. y6 = y1
@. y7 = y2
@. y8 = y3
@. y9 = y4
@. y10 = y5
end
end
has_cuda = CUDA.has_cuda()
AType = has_cuda ? CUDA.CuArray : Array
arr_size = (prod((50, 5, 5, 6, 50)),)
X = get_arrays(:x, arr_size, AType)
Y = get_arrays(:y, arr_size, AType)
test_kernel!(;
unfused! = perf_kernel_shared_reads_writes_unfused!,
fused! = perf_kernel_shared_reads_writes_fused!,
X,
Y,
)
# Compile
perf_kernel_shared_reads_writes_unfused!(X, Y)
perf_kernel_shared_reads_writes_fused!(X, Y)
# Benchmark
benchmark_kernel!(perf_kernel_shared_reads_writes_unfused!, X, Y)
benchmark_kernel!(perf_kernel_shared_reads_writes_fused!, X, Y)
nothing
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 399 | #=
using Revise; include(joinpath("test", "execution", "runtests.jl"))
=#
#! format: off
@safetestset "fused_shared_reads" begin; @time include("bm_fused_shared_reads.jl"); end
@safetestset "fused_shared_reads_writes" begin; @time include("bm_fused_shared_reads_writes.jl"); end
@safetestset "bm_fused_reads_vs_hard_coded" begin; @time include("bm_fused_reads_vs_hard_coded.jl"); end
#! format: on
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | code | 2272 | import Base.Broadcast: broadcasted, instantiate
import BenchmarkTools
import MultiBroadcastFusion as MBF
using Test
import CUDA
function get_array(AType, s)
return AType(zeros(s...))
end
function get_arrays(sym, s, AType, n = 10)
println("array_size = $s, array_type = $AType")
fn = ntuple(i -> Symbol(sym, i), n)
return (; zip(fn, ntuple(_ -> get_array(AType, s), n))...)
end
# benchmarking
function benchmark_kernel!(f!, args...)
println("\n--------------------------- $(nameof(typeof(f!))) ")
trial = benchmark_kernel!(MBF.device(X.x1), f!, args...)
show(stdout, MIME("text/plain"), trial)
end
benchmark_kernel!(::MBF.GPU, f!, args...) =
BenchmarkTools.@benchmark CUDA.@sync $f!($args...);
benchmark_kernel!(::MBF.CPU, f!, args...) =
BenchmarkTools.@benchmark $f!($args...);
function show_diff(A, B)
for pn in propertynames(A)
Ai = getproperty(A, pn)
Bi = getproperty(B, pn)
@show Ai, abs.(Ai - Bi)
end
end
function compare(A, B)
pass = true
for pn in propertynames(A)
pass = pass && all(getproperty(A, pn) .== getproperty(B, pn))
end
pass || show_diff(A, B)
return pass
end
function test_kernel!(; fused!, unfused!, X, Y)
for x in X
x .= map(_ -> rand(), x)
end
for y in Y
y .= map(_ -> rand(), y)
end
X_fused = deepcopy(X)
X_unfused = deepcopy(X)
Y_fused = deepcopy(Y)
Y_unfused = deepcopy(Y)
fused!(X_fused, Y_fused)
unfused!(X_unfused, Y_unfused)
@testset "Test correctness of $(nameof(typeof(fused!)))" begin
@test compare(X_fused, X_unfused)
@test compare(Y_fused, Y_unfused)
end
end
function test_kernel_args!(; fused!, unfused!, args)
(; X, Y) = args
for x in X
x .= rand(size(x)...)
end
for y in Y
y .= rand(size(y)...)
end
X_fused = deepcopy(X)
X_unfused = deepcopy(X)
Y_fused = deepcopy(Y)
Y_unfused = deepcopy(Y)
args_fused = (; X = X_fused, Y = Y_fused)
args_unfused = (; X = X_unfused, Y = Y_unfused)
fused!(args_fused)
unfused!(args_unfused)
@testset "Test correctness of $(nameof(typeof(fused!)))" begin
@test compare(X_fused, X_unfused)
@test compare(Y_fused, Y_unfused)
end
end
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 0.3.1 | 19b2f184b5882538bee0d5355b152212110e0fd2 | docs | 3570 | # MultiBroadcastFusion.jl
A Julia package for fusing multiple broadcast expressions together.
A motivating example of this package is the following:
```julia
x1 = rand(3,3)
x2 = rand(3,3)
x3 = rand(3,3)
x4 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 2 writes, 4 unique reads, but 8 reads including redundant ones
@. y1 = x1 * x2 + x3 * x4
@. y2 = x1 * x3 + x2 * x4
```
In this example, there are 4 unique reads, and 2 writes. However, because the reads are in two separate broadcast expressions, there are 8 reads total, including redundant ones. Another important note is that `y1` and `y2` are stored separately in memory. Fusing these operations can be achieved by changing the memory layout, and adjusting the implementation. For example:
```julia
X = map(x->Tuple(rand(4)),zeros(3,3));
Y = map(x->Tuple(rand(2)),zeros(3,3));
foo(x) = (x[1] * x[2] + x[3] * x[4], x[1] * x[3] + x[2] * x[4])
# 4 reads, 2 writes
@. Y = foo(X)
```
However, this is not an objectively better solution:
- The memory layout, and code implementation, had to be changed in order to make this work, and this can be very difficult for a complex codebase.
- Memory acces of `X` and `Y` is now _strided_, which could result in less performant code than a single fused loop with more contiguous memory.
Ideally, we would like for the loops to be fused with the more contiguous data layouts:
```julia
x1 = rand(3,3)
x2 = rand(3,3)
x3 = rand(3,3)
x4 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 2 writes, 4 unique reads. The compiler can hoist the redundant memory reads here.
for i in eachindex(x1,x2,x3,x4,y1,y2)
y1[i] = x1[i] * x2[i] + x3[i] * x4[i]
y2[i] = x1[i] * x3[i] + x2[i] * x4[i]
end
```
With this package, we can apply `@fused_direct` to reduce the number of reads and preserve the memory layout:
```julia
import MultiBroadcastFusion as MBF
x1 = rand(3,3)
x2 = rand(3,3)
x3 = rand(3,3)
x4 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 4 reads, 2 writes
MBF.@fused_direct begin
@. y1 = x1 * x2 + x3 * x4
@. y2 = x1 * x3 + x2 * x4
end
```
This is achieved by fusing the loops and inlining with the given data, resulting in the compiler being able to perform Common-SubExpression Elimination (CSE) on the memory loads.
## Custom implementations
Users can write custom implementations, using the `@make_type` and `@make_fused` macros, and then defining `Base.copyto!` on the type you've defined
```julia
import MultiBroadcastFusion as MBF
import MultiBroadcastFusion: fused_direct
MBF.@make_type MyFusedMultiBroadcast
MBF.@make_fused fused_direct MyFusedMultiBroadcast my_fused
# Now, `@fused_direct` will call `Base.copyto!(::MyFusedMultiBroadcast)`. Let's define it:
function Base.copyto!(fmb::MyFusedMultiBroadcast)
pairs = fmb.pairs
destinations = map(x->x.first, pairs)
@inbounds for i in eachindex(destinations)
# does `@inline pair.first[i] = pair.second[i]` for all pairs
MBF.rcopyto_at!(pairs, i)
end
return nothing
end
x1 = rand(3,3)
x2 = rand(3,3)
x3 = rand(3,3)
x4 = rand(3,3)
y1 = rand(3,3)
y2 = rand(3,3)
# 4 reads, 2 writes
@my_fused begin
@. y1 = x1 * x2 + x3 * x4
@. y2 = x1 * x3 + x2 * x4
end
```
## Writing custom macros
Users can also write custom macros with, for example,
```julia
import MultiBroadcastFusion as MBF
struct FusedMultiBroadcast{T}
pairs::T
end
macro get_fused_multi_broadcast(expr)
_pairs = gensym()
quote
$_pairs = $(esc(MBF.fused_direct(expr)))
FusedMultiBroadcast($_pairs)
end
end
```
This can be helpful for inspecting multibroadcast objects.
| MultiBroadcastFusion | https://github.com/CliMA/MultiBroadcastFusion.jl.git |
|
[
"MIT"
] | 1.20.0 | 47c6ed345dbabf0de47873514cb6d67369127733 | code | 1115 | cd(@__DIR__)
using Attractors
using Attractors.DynamicalSystemsBase
using Attractors.StateSpaceSets
import Documenter
using Literate
# literate the tutorial
Literate.markdown(
joinpath(@__DIR__, "src", "tutorial.jl"), joinpath(@__DIR__, "src");
credit = false
)
# and the comparison with BFKIT
Literate.markdown(
joinpath(@__DIR__, "src", "bfkit_comparison.jl"), joinpath(@__DIR__, "src");
credit = false,
)
pages = [
"index.md",
"tutorial.md",
"api.md",
"examples.md",
Documenter.hide("bfkit_comparison.md"),
"references.md",
Documenter.hide("recurrences_animation.md"),
]
import Downloads
Downloads.download(
"https://raw.githubusercontent.com/JuliaDynamics/doctheme/master/build_docs_with_style.jl",
joinpath(@__DIR__, "build_docs_with_style.jl")
)
include("build_docs_with_style.jl")
using DocumenterCitations
bib = CitationBibliography(
joinpath(@__DIR__, "refs.bib");
style=:authoryear
)
build_docs_with_style(pages, Attractors, StateSpaceSets;
expandfirst = ["index.md"], bib, warnonly = [:doctest, :missing_docs, :cross_references],
)
| Attractors | https://github.com/JuliaDynamics/Attractors.jl.git |
|
[
"MIT"
] | 1.20.0 | 47c6ed345dbabf0de47873514cb6d67369127733 | code | 11546 | # # [Comparison with traditional local continuation and bifurcation analysis software](@id bfkit_comparison)
# !!! note "Continues from tutorial"
# This page continues after the end of the main [Tutorial](@ref)!
# Ensure you have gon through it first!
# As we discussed in the subsection on [global continuation](@ref global_cont_tutorial),
# the approach of Attractors.jl is fundamentally different from traditional local continuation
# and bifurcation analysis software like AUTO, MatCont, or BifurcationKit.jl.
# Nevertheless in this page we will compare using BifurcationKit.jl
# to attempt to find and continue the limit cycle of the tutorial modified Lorenz-like system.
# We forfeit looking for the chaotic attractors, as to our knowledge there exists no
# software on dynamical systems beyond Attractors.jl can find chaotic attractors.
# The goal of this comparison is to highlight
# the differences in usage complexity and overall capability
# when using Attractors.jl or traditional continuation tools to study
# **complex** dynamical systems.
# ## BifurcationKit.jl version
# To use BifurcationKit.jl (BK) for periodic orbits (POs) we need to choose one of its
# several Newton-based algorithms for POs, and in addition supply it with
# both an initial guess for the location of the periodic orbit, as well as
# a guess for the period.
# In this example we translate almost verbatim the example of the [Periodic predator prey model](https://bifurcationkit.github.io/BifurcationKitDocs.jl/v0.3/tutorials/ode/tutorialsCodim2PO/#Periodic-predator-prey-model)).
# from the BK docs. Finding a periodic orbit this way is already considered
# an advanced use case in BK documentation,
# requiring "high level of knowledge of (numerical) bifurcation theory".
# For Attractors.jl on the other hand, this is as basic of a use-case as it can get,
# which highlights the simplicity of our computational approach.
# To use BK we need to import it and initialize
# various continuation-related structures.
# The entire input BK requires to find a periodic orbit is:
# 1. a periodic orbit problem like `BK.ShootingProblem` or `BK.PeriodicOrbitTrapProblem`
# (and its meta parameters)
# 1. a `BK.BifurcationProblem`
# 1. a `DifferentialEquations.Solution`
# 1. an estimate of the period
# 1. a `BK.ContinuationPar` parameter container
# 1. a predictor for the continuation
# 1. arguments for what aspect of the periodic orbit to record.
# Some of this input isn't particularly important,
# but some of it is can be crucial and the values of the meta-parameters matter
# for whether the continuation will succeed or not.
# Let's start with the bifurcation problem.
# This is basically the same thing as a `DynamicalSystem`, but BK does not
# support efficient `StaticVector`-based out of place format for low dimensional
# systems (see main tutorial of DynamicalSystems.jl if you don't understand what this means).
# So we have to re-create
## BK requires to modify the rule with t=0 as well
function modified_lorenz_rule!(du, u, p, t = 0)
x, y, z = u; a, b = p
du[1] = y - x
du[2] = - x*z + b*abs(z)
du[3] = x*y - a
return du
end
prange = 4.7:0.02:6
pidx = 1
p0 = [5.0, 0.1] # parameters
u0 = [-4.0, 5, 0] # state
# %% #src
# Now we can create the bifurcation problem
import BifurcationKit as BK
using OrdinaryDiffEq
using CairoMakie
bf_prob = BK.BifurcationProblem(
modified_lorenz_rule!, u0, p0, (BK.@lens _[pidx])
)
# and then a full solution structure from DifferentialEquations.jl, that
# **must** start on the periodic orbit. Requiring that the solution
# starts on the periodic orbit defeats the purpose of "wanting to find it",
# but oh well, we do as we must.
## This guess comes from the Attractors.jl main tutorial
point_on_lc = [
-1.622956992666447,
-4.527917984019188,
-5.178825669659272,
]
ode_prob = ODEProblem(modified_lorenz_rule!, point_on_lc, (0.0, 100.0), p0)
sol = OrdinaryDiffEq.solve(ode_prob; alg = Vern9(), abstol = 1e-9, reltol = 1e-9)
j = length(sol)Γ·2
fig, ax = lines(sol.t[j:end], sol[1, j:end])
lines!(ax, sol.t[j:end], sol[2, j:end])
lines!(ax, sol.t[j:end], sol[3, j:end])
fig
# We need an estimate of the period besides providing the full DifferentialEquations.jl
# solution. From the figure this appears to be around 20.0 (note: the periodic
# orbit wraps around four times before repeating exactly).
# Right, and lastly we need a continuation parameter container,
# which has some options regarding convergence and stability that one
# would need to fine tune to the problem at hand.
opts_br = BK.ContinuationPar(
p_min = prange[1], p_max = prange[end],
ds = 0.002, dsmax = 0.01, n_inversion = 6,
detect_bifurcation = 3, max_bisection_steps = 25, nev = 4,
max_steps = 2000, tol_stability = 1e-3,
)
# We now create a periodic orbit problem type, by choosing a periodic
# orbit finding algorithm
periodic_orbit_algo = BK.PeriodicOrbitOCollProblem(40, 4)
# and creating the problem type giving the period guess 19.0
probpo, cish = BK.generate_ci_problem(
periodic_orbit_algo, bf_prob, sol, 19.0
)
# To call the continuation we need to also tell it what aspects of the
# periodic orbit to record, so we define
argspo = (record_from_solution = (x, p) -> begin
xtt = BK.get_periodic_orbit(p.prob, x, p.p)
return (max = maximum(xtt[1,:]),
min = minimum(xtt[1,:]),
period = BK.getperiod(p.prob, x, p.p),
p = p.p,)
end,
)
# we also define the predictor
predictor = BK.PALC(tangent = BK.Bordered())
# and _finally_ call the continuation from BK
@time branch = BK.continuation(probpo, cish, predictor, opts_br;
verbosity = 0, plot = false, argspo...
)
stability = branch.stable
color = [s ? "black" : "red" for s in stability]
marker = [s ? :circle : :x for s in stability]
scatter(branch.branch.p, branch.branch.min; color, marker)
# The above code takes about 5 seconds to run.
# Thankfully it works. Or rather, almost.
# The code finds no stable limit cycle for parameter less than 5.0,
# even though we know (see Tutorial final plot) that there is one.
# Or maybe, it is an extremely weakly chaotic attractor with MLE almost 0.
# Or maybe it is a quasiperiodic attractor. One needs to analyze further,
# but Attractors.jl finds everything without much difficulty.
# Altering the above code to start the continuation at 4.7 finds a limit cycle
# there, but only manages to continue it only up to parameter 4.74,
# instead of well into parameter 5.5 or more that Attractors.jl shows.
# ## Attractors.jl version
# We have already seen the code for this version in the main [Tutorial](@ref tutorial),
# but here we copy it again using exactly the same input as that given to BK.
# To make the comparison explicit, let's also make an enumerated list for
# the Attractors.jl info:
# 1. A `DynamicalSystem`,
# 1. an `AttractorMapper` instance (and its meta parameters).
# For the mapper used here, `AttractorsViaRecurrences`, the meta parameters are:
# 1. A state space tesselation
# 1. A recurrence threshold
# 1. A lost iterations threshold
# 1. a global continuation algorithm, and optionally a matcher for it.
# 1. a sampler to sample initial conditions in the state space.
# %% #src
using Attractors
ds = CoupledODEs(modified_lorenz_rule!, u0, p0;
diffeq = (alg = Vern9(), abstol = 1e-9, reltol = 1e-9)
)
grid = (
range(-15.0, 15.0; length = 200), # x
range(-20.0, 20.0; length = 200), # y
range(-20.0, 20.0; length = 200), # z
)
mapper = AttractorsViaRecurrences(ds, grid;
consecutive_recurrences = 1000,
consecutive_lost_steps = 100,
)
sampler, = statespace_sampler(grid)
algo = AttractorSeedContinueMatch(mapper)
fractions_cont, attractors_cont = global_continuation(
algo, prange, pidx, sampler; samples_per_parameter = 1_000
)
plot_attractors_curves(
attractors_cont, A -> minimum(A[:, 1]), prange,
)
# This code takes about 15 seconds to run.
# This number however is for 1000 initial conditions, not one (i.e., the one
# branch generated during the traditional continuation).
# ## Discussion and comparison
# Attractors.jl found not only a single limit cycle,
# but also all system attractors, including chaotic ones.
# It didn't require any initial guess regarding the limit cycle or its period,
# but only a state space box that may contain attractors.
# Attractors.jl is extremely robust w.r.t. to its input parameters:
# the state space box can be arbitrarily large, as long as it is large enough.
# Similarly, all meta parameters of `AttractorsViaRecurrences` only need to be
# large enough; the larger, the more accurate the result.
# These algorithms are also robust in the sense of working well for
# many different types of dynamical systems, including discrete ones,
# see [Datseris2022](@cite) for a demonstration.
# And finally, Attractors.jl estimates a more general nonlocal measure of stability,
# in the sense that if a set is nonlocally stable, it is guaranteed to be locally stable,
# however the other way around isn't guaranteed.
# Moreover, due to the orthogonality of finding and matching attractors,
# as well as finding _all_ attractors, the global continuation of Attractors.jl
# can continue along arbitrary user-defined curves in parameter space; not just
# along a single parameter axis. This is possible because it is completely fine
# for some attractors to stop existing during the global continuation,
# while local continuation stops when attractors (and their unstable version)
# stop existing.
# Traditional local continuation can track the unstable
# branches, and automatically detect and label local bifurcations,
# both of which are not possible in Attractors.jl
# (note we didn't bother to plot any of the detected bifurcations - if any are found).
# In our experience having the local bifurcations is always useful.
# Now, whether the unstable branches are of a limit cycle are useful or not,
# depends on the research question and whether the analysis is done for some
# sort of real world understanding (unstable limit cycles / fixed points don't
# actually exist in the real world).
# Beyond this however, BifurcationKit.jl is also optimised for PDE systems,
# while Attractors.jl isn't.
# Now, we have to be a bit more transparent here.
# Besides this absence of stable orbits for parameter less than 5.0
# that we discussed in the end of the BifurcationKit.jl version,
# we need to say that it took **a lot of effort** to make the
# BifurcationKit.jl code work. At least, a lot of effort compared with the effort
# it took to make the Attractors.jl version work, which was simply "increase the recurrences
# threshold", which is standard practice when dealing with chaotic systems
# [Datseris2022](@cite). For example, any other of the
# periodic orbit algorithms of BifurcationKit.jl (such as shooting or trapezoid) fails.
# Using a slightly incorrect initial period guess of 20.0 instead of 19.0 also fails.
# We imagine that this sensitivity would apply also to some other of the
# several meta-parameters that enter a traditional continuation routine,
# for example the thresholds and accuracy parameters related to Newton convergence,
# but we didn't check further. This is exactly what we were alluding to
# in the comparison we did in [Datseris2023](@cite), that traditional
# local continuation "requires expertise and constant interventions".
# See [Datseris2023](@cite) for a more thorough comparison
# (that was based on and older and less powerful version of Attractors.jl). | Attractors | https://github.com/JuliaDynamics/Attractors.jl.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.