Jump to content

How to compile vfl library files to use in wrangles


DonRomano

Recommended Posts

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,

Link to comment
Share on other sites

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 by Stalkerx777
Link to comment
Share on other sites

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 by DonRomano
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...