Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cc] Compose ActionRecorder outputs into a single C file for Emscripten #1629

Merged
merged 18 commits into from
Aug 4, 2020

Conversation

archibate
Copy link
Collaborator

@archibate archibate commented Aug 2, 2020

Related issue = #

[Click here for the format server]


Usage e.g.:

TI_ACTION_RECORD=mpm88.yml TI_ARCH=cc python examples/mpm88.py
ti cc_compose mpm88.yml mpm88.c
emcc mpm88.c -o mpm88.js

Then write a mpm88.html that includes taichi.js and mpm88.js and the following inline scripts:

let taichi = new Taichi(Module);
let N = 8192;
let RES = 512;

taichi.ready(function() {

    let canvas = document.getElementById('canvas');
    let gui = new TaichiGUI(canvas, RES);

    let matrix_to_ext_arr = taichi.get('matrix_to_ext_arr_c20_0');
    let substep = taichi.get('substep_c4_0');
    let init = taichi.get('init_c6_0');

    init();

    gui.animation(function() {
        for (let i = 0; i < 5; i++) {  // fps extreme when 50
            substep();
        }
        let extr = taichi.set_ext_arr(0, [N, 2]);  // index, array shape
        matrix_to_ext_arr();

        gui.circles(extr);  // updated, since extr is a ref
    });
});

See https://github.com/taichi-dev/taichi.js for client, please run python server.py to set up a simple http server, it won't work in file:///.
Btw, I forget to grant myself with admin permission while transfer... LOL, @yuanming-hu Would you mind restore me with admin and make the taichi.js repo to be public so that people could share it?

@codecov
Copy link

codecov bot commented Aug 2, 2020

Codecov Report

Merging #1629 into master will decrease coverage by 0.70%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1629      +/-   ##
==========================================
- Coverage   45.00%   44.29%   -0.71%     
==========================================
  Files          40       41       +1     
  Lines        5739     5858     +119     
  Branches     1002     1017      +15     
==========================================
+ Hits         2583     2595      +12     
- Misses       3002     3116     +114     
+ Partials      154      147       -7     
Impacted Files Coverage Δ
python/taichi/cc_compose.py 0.00% <0.00%> (ø)
python/taichi/core/util.py 0.29% <0.00%> (-0.01%) ⬇️
python/taichi/main.py 23.73% <0.00%> (-0.40%) ⬇️
python/taichi/testing.py 76.92% <ø> (ø)
python/taichi/lang/__init__.py 54.75% <0.00%> (-0.46%) ⬇️
python/taichi/misc/gui.py 0.00% <0.00%> (ø)
python/taichi/lang/kernel.py 68.71% <0.00%> (ø)
python/taichi/lang/impl.py 66.18% <0.00%> (+0.09%) ⬆️
python/taichi/lang/matrix.py 67.47% <0.00%> (+0.15%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81437d6...5ec8dc6. Read the comment docs.

Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Just some minor issues that need a little clarification.

python/taichi/cc_compose.py Outdated Show resolved Hide resolved
{ActionArg("kernel_name", name), ActionArg("arg_id", i),
ActionArg("address", fmt::format("0x{:x}", ptr)),
ActionArg("array_size_in_bytes", (int64)size)});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still people using information like set_kernel_arg_int64. Can we keep these for now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it doesn't even include dtype... They are just spams in our compile-only no-launch action parser, both in CC and [数据删除] in my pratice...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there are still people depending on this. I don't think we should remove them immediately. Maybe a better solution is to mark them as a different type of message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the feature is purposely undocumented and used by only you and me and the [数据删除]? Also did you confirmed this doesn't harm performance? IMO we'd remove all the run-time action output iapr, since only compile-time kernel information are required for reconstructing a Taichi program outside, e.g., this PR, did that easily.

python/taichi/core/util.py Outdated Show resolved Hide resolved
python/taichi/core/util.py Outdated Show resolved Hide resolved
python/taichi/core/util.py Outdated Show resolved Hide resolved
@archibate archibate requested a review from yuanming-hu August 2, 2020 05:59
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, much better now. I still suggest keeping the kernel argument information.

python/taichi/core/util.py Outdated Show resolved Hide resolved
python/taichi/core/util.py Outdated Show resolved Hide resolved
{ActionArg("kernel_name", name), ActionArg("arg_id", i),
ActionArg("address", fmt::format("0x{:x}", ptr)),
ActionArg("array_size_in_bytes", (int64)size)});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there are still people depending on this. I don't think we should remove them immediately. Maybe a better solution is to mark them as a different type of message.

archibate and others added 2 commits August 3, 2020 00:42
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
@archibate archibate requested a review from yuanming-hu August 2, 2020 16:47
python/taichi/core/util.py Outdated Show resolved Hide resolved
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you so much!

python/taichi/core/util.py Outdated Show resolved Hide resolved
@yuanming-hu yuanming-hu changed the title [cc] Compose ActionRecorder output into single C file for Emscripten [cc] Compose ActionRecorder outputs into a single C file for Emscripten Aug 4, 2020
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
@archibate archibate added the LGTM label Aug 4, 2020
@archibate archibate merged commit 0564052 into taichi-dev:master Aug 4, 2020
@yuanming-hu yuanming-hu mentioned this pull request Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants