Skip to content

[WIP] Fix and improve parrot vs thrust example code - #71

Open
qqii wants to merge 20 commits into
NVlabs:mainfrom
qqii:qqii/parrot-vs-thrust
Open

[WIP] Fix and improve parrot vs thrust example code#71
qqii wants to merge 20 commits into
NVlabs:mainfrom
qqii:qqii/parrot-vs-thrust

Conversation

@qqii

@qqii qqii commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Really cool project, I wanted to have a go but found some of the parrot vs thrust example code misleading, which slightly inflates the code reduction. Unfortunately I haven't been able to get a working dev environment, so these changes were made purely by referring to the docs.

A common bug I found was translating

thrust::default_random_engine rng;
thrust::uniform_int_distribution<int> dist(10, 99);

thrust::host_vector<int> host_data(N);
for (auto &e : host_data) {
  e = dist(rng);
}

into

         // parrot::scalar(99).repeat(10).rand();
auto host = parrot::scalar(89).add(10).repeat(10).rand();

rather than

auto host = parrot::scalar(89).repeat(10).rand().add(10);

There are also a handful of features that are undocumented. I'd love to get some advice as to where I should take this. Here were some of my thoughts:

TODO

  • figure out why devcontainers doesn't work for me on windows
  • run builds and formatting
  • fix expected outputs
  • try to exactly match thrust stdout?
  • better match variable names, structure and code comments?
  • rebase

To Consider

  • seed random for reproducible outputs?
  • line breaking strategy for readability and useful ratio
  • // todo comments
    • range(start, end)
    • understand how operator= works
    • operator[] (multidimensional in C++23!)
    • multisample monte carlo,
  • bench parrot against thrust?
  • review "real world examples"

qqii added 20 commits November 12, 2025 21:11
- `build-docs.sh` uses uv to run `generate_comparisons.py`
- fix path `script` -> `scripts`
The thrust code has `uniform_int_distribution<int> dist(10, 99)`.
still missing arg passing, exaggerating ratio
also removed reshape, which wasn't in the thrust example?
- extract vars: R, C
- fix random distribution [10, 89] (not [0, 99])
it could be argued that the intermiddiate prints should not be included as part of the ratio
- extract vars: lo, hi
- add missing print, negated values
- rename args to match thrust example
something is filtering the entire block if it contains `// TODO`
Matches the thrust code. An example of using scalar repeat is found in the saxpy example.
@codereport

Copy link
Copy Markdown
Collaborator

Thanks for this PR! Let me know if I can help with the devcontainer issues. I don't have Windows but I still might be able to help troubleshoot. Looks like other than clang-format, ci is passing. Although there is a GHA that runs the example tests and thrust comparisons - so we should run that on this branch as well.

@qqii

qqii commented Nov 22, 2025

Copy link
Copy Markdown
Contributor Author

I've figured something out, I think it's to do with how the Dockerfile or docker-compose.yml handles the PATH. This is the output I get on Windows:

# docker compose exec parrot-dev bash
time="2025-11-22T04:15:46Z" level=warning msg="The \"LD_LIBRARY_PATH\" variable is not set. Defaulting to a blank string."
OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH

The ">Dev Containers: Clone Repository in [Named] Container Volume..." option didn't work either, but things work fine under my Debian WSL instance (as it should).

Looking at my devcontainer logs, the problem seems to be that PATH is being expanded to my full Windows path?


As I've got something working, I'll start fixing it up this PR first.

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