taichi.jl

Using Taichi in Julia!

https://github.com/lucifer1004/taichi.jl

Science Score: 41.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.8%) to scientific vocabulary

Keywords

julia taichi
Last synced: 10 months ago · JSON representation ·

Repository

Using Taichi in Julia!

Basic Info
  • Host: GitHub
  • Owner: lucifer1004
  • License: mit
  • Language: Julia
  • Default Branch: main
  • Homepage:
  • Size: 43.5 MB
Statistics
  • Stars: 41
  • Watchers: 3
  • Forks: 1
  • Open Issues: 2
  • Releases: 0
Topics
julia taichi
Created almost 4 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

Taichi.jl

Stable Dev Build Status Coverage

Taichi.jl is a thin wrapper around Taichi. It is built upon two packages:

  • PythonCall.jl which makes Julia & Python easily interoperable.
  • Jl2Py.jl which transpiles Julia code to Python.

The general workflow is as follows:

txt ||==========|| ||==========|| ||==========|| || Julia || Taichi.jl || Python || Taichi || Taichi || || || || || (via PythonCall)|| || || kernel || ===========> || kernel || ===========> || kernel || ||==========|| ||==========|| ||==========||

There is a language-agnostic Taichi IR called Chi under development. After Chi becomes stable, we will switch to directly transpilation from Julia AST to Chi IR.

Usage

Taichi.jl is very simple to use. The Python module taichi is exported as a constant ti. Then you can call most functions exactly the same way as in Python.

For wrapping kernel functions, two macros are exported, namely, @ti_func and @ti_kernel. The typical usage is to put the macro in front of an anonymous function, then assign it to a variable.

Following is a Julian adaptation of the "Julia set" example. Take caution that Python boolean values cannot be directly used in Julia, and we need to use helper functions like pytruth and pyeq. More examples can be seen in examples.

```julia using Taichi

let ti.init(; arch=ti.gpu) n = 640 pixels = ti.Vector.field(3; dtype=pytype(1.0), shape=(n * 2, n))

paint = @ti_kernel (t::Float64) -> for (i, j) in pixels
    c = ti.Vector([-0.8, ti.cos(t) * 0.2])
    z = ti.Vector([i / n - 1, j / n - 0.5]) * 2
    rgb = ti.Vector([0, 1, 1])
    iterations = 0
    while z.norm() < 20 && iterations < 50
        z = ti.Vector([z[0]^2 - z[1]^2, z[0] * z[1] * 2]) + c
        iterations += 1
        pixels[i, j] = (1 - iterations * 0.02) * rgb
    end
end

gui = ti.GUI("Julia Set"; res=(n * 2, n))
i = 0
flag = 0
while pytruth(gui.running)
    if flag == 0
        i -= 1
        if i * 0.02 <= 0.2
            flag = 1
        end
    else
        i += 1
        if i * 0.02 > (π * 1.2)
            flag = 0
        end
    end

    paint(i * 0.02)
    gui.set_image(pixels)
    gui.show()
end

end ```

Screenshot of the example above:

Julia Set

You can run it from the repository root:

bash julia --project=. examples/juliaset.jl

More Examples

Game of Life

Game of Life GIF

bash julia --project=. examples/gameoflife.jl

FEM99

FEM99 GIF

bash julia --project=. examples/fem99.jl

Owner

  • Name: Gabriel Wu
  • Login: lucifer1004
  • Kind: user
  • Location: Beijing, China
  • Company: @NVIDIA

DevTech Compute @ NVIDIA

Citation (CITATION.bib)

@misc{Taichi.jl,
	author  = {Gabriel Wu <wuzihua@pku.edu.cn> and contributors},
	title   = {Taichi.jl},
	url     = {https://github.com/lucifer1004/Taichi.jl},
	version = {v0.1.0},
	year    = {2022},
	month   = {7}
}

GitHub Events

Total
Last Year

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 24
  • Total Committers: 2
  • Avg Commits per committer: 12.0
  • Development Distribution Score (DDS): 0.042
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Gabriel Wu w****a@p****n 23
Cherichy c****y@o****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 1
  • Total pull requests: 6
  • Average time to close issues: less than a minute
  • Average time to close pull requests: 3 days
  • Total issue authors: 1
  • Total pull request authors: 4
  • Average comments per issue: 5.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 5
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • JuliaTagBot (1)
Pull Request Authors
  • github-actions[bot] (3)
  • imgbot[bot] (1)
  • cherichy (1)
  • renovate[bot] (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/CI.yml actions
  • actions/checkout v2 composite
  • codecov/codecov-action v2 composite
  • julia-actions/cache v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-docdeploy v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/CompatHelper.yml actions
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite