DonRomano Posted April 14, 2021 Share Posted April 14, 2021 Hey, I've asked this question a on SideFX forum but I didn't have any answer, so I try here. I've been struggling on this lately and didn't found how to do it properly. I've made a few .vfl files with functions definitions, and I'd like to compile them and then call them in attribute wrangles (to gain some performance and avoid compilation each time the code is run (especially with heavy functions)). The way I tested was : test.vfl : #ifndef TEST #define TEST cvex print(string message="") { printf(message); } #endif vcc test.vfl -> outputs a print.vex file I define HOUDINI_VEX_PATH to include the directory where print.vex isin Houdini, in an attr wrangle : #include "print.vex" print("test message"); And I have a warning : "Errors or warnings encountered during VEX compile: /obj/geo1/pointwrangle1/attribvop1: No context function defined.. " though I've defined the context if the function (cvex). If anyone knows the proper way to do this (if it's possible), let me know.. Cheers, Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted April 16, 2021 Share Posted April 16, 2021 (edited) cvex is sort of generalized context ( computational vex - not sure if it's real of I made this up ) it could be useful for some times to abstract from context (SOP, DOP, Shaders) but if you don't have a strong requirement to make it so general, just stick to regular functions, save them to a .h file and then #include it. Houdini will compile it for you. You won't get any benefits from pre-compile your code manually with vcc For reference: https://www.sidefx.com/forum/topic/41253/ Edited April 16, 2021 by Stalkerx777 Quote Link to comment Share on other sites More sharing options...
DonRomano Posted April 16, 2021 Author Share Posted April 16, 2021 (edited) 32 minutes ago, Stalkerx777 said: cvex is sort of generalized context ( computational vex - not sure if it's real of I made this up ) it could be useful for some times to abstract from context (SOP, DOP, Shaders) but if you don't have a strong requirement to make it so general, just stick to regular functions, save them to a .h file and then #include it. Houdini will compile it for you. You won't get any benefits from pre-compile your code manually with vcc For reference: https://www.sidefx.com/forum/topic/41253/ Yeah I tried to use the cvex context to make it general, but I think pre compiling headers can help with performance when you have large functions. I've already made libraries in header files, but I think that if I can pre compile some functions it could help the wrangles (when sometimes this wrangle is cooked millions of time, I think it can speed up the computation (though vex generated code is cached, we could avoid this step too)). Or maybe there is another way of compiling code ? I don't know if wrangles in hda are compiled at hda creation/modification, or jit compiled like normal wrangles. If nothing changes with manual compilation then it's fine and I already have the maximum performance, but if there is a way of optimizing this I'll be glad to read about it Cheers, Edited April 16, 2021 by DonRomano Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted April 19, 2021 Share Posted April 19, 2021 Drop a SOP/Attribute VOP and check out the Compiler parameter. All wrangle nodes compile you code once and it's very fast. You won't get any execution performance benefits from pre-compiling. I don't know the size of your code, but the one I once worked with was a couple of thousand LOC in a header file and wrangle nodes chewed them almost instantly. Cheers. Quote Link to comment Share on other sites More sharing options...
DonRomano Posted April 20, 2021 Author Share Posted April 20, 2021 Oh okay, I thought the code was compiled each time the wrangle was cooked (in a for loop). I wasn't sure that I already had the max performances on this, but thanks for the precisions ! Cheers, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.