Is it possible to use nvstd::function inside an RTC agent function? #1199
-
Hello there! :) I would love some hints/clarifications/help for using additional std-library or cuda C++ headers in agent functions. #include <nvfunctional> I get the following error: (venv) [me@cgpu01-002 model-socix-py]$ python sx.py -s 2
crt/nvfunctional(50): warning: new: [jitify] File not found
---------------------------------------------------
--- JIT compile log for human_behavior_program ---
---------------------------------------------------
crt/nvfunctional(86): error: namespace "std" has no member "is_move_constructible"
crt/nvfunctional(86): error: type name is not allowed
crt/nvfunctional(87): error: expected a "," or ">"
crt/nvfunctional(87): error: the global scope has no "value"
crt/nvfunctional(87): error: expected a ";"
crt/nvfunctional(118): warning: parsing restarts here after previous syntax error
human_behavior_impl.cu(47): warning: variable "actions" was declared but never referenced
5 errors detected in the compilation of "human_behavior_program".
---------------------------------------------------
Traceback (most recent call last):
File "/work/me/model-socix-py/sx.py", line 304, in <module>
main()
File "/work/me/model-socix-py/sx.py", line 290, in main
simulation.initialise(sys.argv)
File "/work/me/model-socix-py/venv/lib/python3.11/site-packages/pyflamegpu/pyflamegpu.py", line 8830, in initialise
return _pyflamegpu.Simulation_initialise(self, argc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyflamegpu.pyflamegpu.FLAMEGPURuntimeException: (InvalidAgentFunc) /__w/FLAMEGPU2/FLAMEGPU2/src/flamegpu/detail/JitifyCache.cu(422): Error compiling runtime agent function (or function condition) ('human_behavior'): function had compilation errors (see std::cout), in JitifyCache::buildProgram(). So the header is found but there are some compilation errors. Note that Just loading RuntimeError: human_behavior_impl.cu not in loaded sources! This may be due to a header being loaded by NVRTC without Jitify's knowledge. So maybe the std::function is just not supposed to be used in CUDA code? Or is this a restriction of FLAMEGPU's JIT compilation code? Would love to get some input! :) [1] https://docs.flamegpu.com/guide/agent-functions/defining-agent-functions.html |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
We use Jitify to handle runtime compilation (RTC). RTC does not have access to the C++ standard library includes. For this reason, Jitify provides shims for a subset of the standard library headers. It would appear that nvfunctional uses something that is not currently shimmed by Jitify ( You could submit an issue or pull request to jitify requesting/providing the shim. Myself and others have provided PRs to extend the shims in the past. We currently use Jitify1, but hope to move to Jitify2 in the near future when their pre-processor PR is merged. In their repository, they maintain the versions in two separate branches. |
Beta Was this translation helpful? Give feedback.
We use Jitify to handle runtime compilation (RTC).
RTC does not have access to the C++ standard library includes. For this reason, Jitify provides shims for a subset of the standard library headers.
It would appear that nvfunctional uses something that is not currently shimmed by Jitify (
std::is_move_constructible
).You could submit an issue or pull request to jitify requesting/providing the shim. Myself and others have provided PRs to extend the shims in the past. We currently use Jitify1, but hope to move to Jitify2 in the near future when their pre-processor PR is merged. In their repository, they maintain the versions in two separate branches.