Beta Gen Documentation

Oct 18, 2011 at 3:53pm

Beta Gen Documentation

hello everyone. This information will be included with the next release, but until then here is some beta documentation describing the new Gen technology. Any feedback is appreciated, particularly if there are subjects that could use more detail or are missing, confusing terminology or descriptions, …

Here’s the link:

http://www.cycling74.com/download/gen.documentation.beta.pdf

#59406
Oct 18, 2011 at 4:00pm

Hi Wesley,

Jumping the gun a bit, but will there be an SDK for [gen~] operators at any point? That would really be the icing on the cake.

#213728
Oct 18, 2011 at 4:25pm

An SDK is something we are hoping for a future release (no promises although I really want to see it too). I will say it won’t be in a 6.0 release though.

#213729
Oct 18, 2011 at 8:20pm

Excellent document – like many others I am very enthusiastic about gen and its Jitter cousins. A few questions:

- GenExpr language: in the case of only being interested in one return value from an expression, the document describes the case where you assign the first return value to a variable but discard the second. Is there a way to reverse this – to discard the first return value and assign the second?

- is the namespace in codebox global – i.e. if I define a function in one codebox can it be called in another?

- is it possible to add the equivalent of the history operator in a jit.gen or (more importantly) jit.gl.gen context? This would be an extremely elegant way to allow for feedback processes, but I don’t know if it’s feasible. As FBO’s are not readable in GLSL I’d imagine the answer is no, but worth asking.

#213730
Oct 18, 2011 at 8:30pm

“- GenExpr language: in the case of only being interested in one return value from an expression, the document describes the case where you assign the first return value to a variable but discard the second. Is there a way to reverse this – to discard the first return value and assign the second?”

// the Gen compiler does dead code elimination, so the variable “notused” won’t actually be used
notused, myvar = cartopol(in1, in2);
out1 = myvar;

“- is the namespace in codebox global – i.e. if I define a function in one codebox can it be called in another?”

not currently. We will support some kind of import message in the near near future that will load in files of
function definitions

“- is it possible to add the equivalent of the history operator in a jit.gen or (more importantly) jit.gl.gen context? This would be an extremely elegant way to allow for feedback processes, but I don’t know if it’s feasible. As FBO’s are not readable in GLSL I’d imagine the answer is no, but worth asking.”

No. None of the Gen objects support this operator. As you can imagine, for the history operator, we’d have to create a temporary buffer the size of the input matrix for this to work. While technically feasible in jit.gen and jit.pix, it’s not at all possible in jit.gl.pix. Since the jitter Gen objects don’t suffer from the “single sample” delay problem that MSP objects do in feedback situations, I don’t think it’s much of a burden to require feedback jitter Gen patchers require the user to loop the output back to a second input.

#213731
Oct 18, 2011 at 8:49pm

> Here's the link:
> http://www.cycling74.com/download/gen.documentation.beta.pdf

Most pictures in the first pages of the document are incorrectly displayed in Adobe Reader (8.1.1) (but are OK in MacOS X's Preview app).

[attachment=173395,2736]

Attachments:
  1. genmanualpictureproblem.png
#213732
Oct 18, 2011 at 8:52pm

Thanks Wesley – all confirming what I had guessed. It’s good to hear that you will support function import at some point in the future.

#213733
Oct 18, 2011 at 8:55pm

Thanks Roald. I’m seeing the same in Acrobat Pro. Really odd! Looks like the print to PDF function munged some things up.

#213734
Oct 18, 2011 at 8:57pm

Really useful document, thanks! I’ve been muddling along with gen~ for the last few days but this makes things much clearer.

A small question – is it possible to use the history operator within a codebox? It currently throws up an error, so I’m guessing it’s not allowed. That’s a shame if so. It’d be a great way to easily implement more unwieldy filters.

#213735
Oct 18, 2011 at 9:11pm

Hi Bacchus,
In the beta, we didn’t get to implementing History in a codebox, but for the release this is already in there. The syntax will like this:

y = x + 1; // fwd use of x
x = history(y * 2);
out = y;

note that x is used before it’s assigned to. This will _only_ be allowed for feedback operations and we enforce that strictly. Anything else will throw errors.

#213736
Oct 18, 2011 at 9:53pm

Ok, that’s great to hear! Looking forward to the release version!

#213737
Oct 19, 2011 at 3:38am

Because you asked for comments…

I think it will be very helpful if the docs would answer the following:

1. What are the intended usages? This would need to be supported by examples showing some contrasting implementations as working and commented patches.

2. What are the performance (or other) gains? This would need to be supported by evidence in the form or working and commented patches showing parallel performance with contrasting setups (gen/not gen). It would also be good to have similar working patches highlighting the areas of applications where the advantages can be greatest. And some text explaining where the advantages are unlikely.

Hope you agree. Thanks.

#213738
Oct 19, 2011 at 12:16pm

+1.

despite the fact I understand that gen is supposed to be used for more versed users in programming, which is not my case, I would really appreciate to have the use of gen made more clear for a broader audience. I intend to put my efforts on learning how to use gen and the suggestions from jhdkfj39929 sounds very interesting in helping on it.

#213739
Oct 19, 2011 at 5:13pm

hi sandroid. Gen is a lower-level patching environment, but our goal is certainly not to limit it to a certain level of user. It should be accessible to everyone. If you have any other ideas or comments about what is/isn’t accessible in terms of how Gen is presented in the documentation, please post them here. thanks!

#213740
Oct 19, 2011 at 5:19pm

I just posted in this thread something which might be relevant to jhdkfj39929′s questions:

http://cycling74.com/forums/topic.php?id=35704

#213741
Oct 19, 2011 at 6:32pm

thanks wesley and Joshua. I start grasping the reason for really put myself into gen.
I am looking forward for the examples Joshua mentioned in his post. I think they could help “lastminute programmers” like me, who have never programmed anything before getting in touch with max. Related to this, which directions you could point me as a initial ground to start with? in other words: should I get acquainted with languages like C, C++, Java, or even OpenGL, shaders programming before going into gen or gen some how will be self-explanatory. will I need some background on program paradigms (how to organize the program in variables, functions, etc.)?
In general terms, how can somebody who has learned programming from a graphical oriented environment (and its data flow paradigm) be able to grasp this low level programming? I suspect this question goes far being the scope of this forum. But maybe I am wrong…
Anyways, things are getting really exciting with max6 (I have been patching with Jitter – my main interest- last days,and I am very excited with the new possibilities). Somehow I can recover the same thrilling feeling I had in the first time I saw and played with Max in 2001.

thanx

#213742
Oct 19, 2011 at 7:01pm

Hi sandroid,
This is a good question. You shouldn’t require any special programming knowledge to get started with Gen. In many instances, you will probably find Gen to be very similar to patching in a standard Max patch. I would recommend looking through the included Gen examples and trying to do a little patching yourself to get a better idea. Like anything, it will take some time to get acquainted with all the features and workflow, but if you are already familiar with Max and Jitter, a lot of that knowledge will translate. My advice would be (like learning Max) to start small and try building some simple things, and scale up as you get more confident.

#213743
Oct 19, 2011 at 9:26pm

Can we have loops in codebox pls?
Also, no arrays, why are there no arrays? I want to be able to make arrays of history etc…

#213744
Oct 19, 2011 at 9:37pm

@veqtor For arrays, I believe you can use data with peek and poke for now. Loops will be coming eventually.

@sandriod Just wanted to reiterate what Andrew said. There’s no need to know C or GLSL to start using gen. If you start using codebox, the expression syntax is very simple and if you study any text programming language like JS, Java, GLSL, etc. many of the ideas should translate.

#213745
Oct 19, 2011 at 10:14pm

Some simple synthetic benchmark examples in the other thread:

http://cycling74.com/forums/topic.php?id=35704#post-173546

#213746
Oct 19, 2011 at 11:16pm

Thank you. Very helpful. I look forward to more examples. Generally, while MAX documentation and tutorials are very good, I feel one type of storytelling is not very well represented. And this is showing/evidencing via completed projects of some sophistication and of immediate aesthetic value (witness Epic Games trying to impress with the demos like Samaritan – cheesy, yes – but advanced).

(Perhaps I should disclose that I am more interested in Jitter and that the audio side of things might be much more mature – I cannot judge.)

Take for example the available tutorials for drawing or shading in MAX 5 (Tutorials 40 and 41). Or, in fact for most of visual processing. They present some(many) option and demonstrate some working setups but the demonstrations are not intended to be visually convincing. In fact, the functionality they show is basic and the outcomes are ubiquitous to many other systems. So, it is hard for students (or even expert users working outside of their typical specialization) to appreciate what is possible or visualize the path from idea to implementation. Or to appreciate the unique strengths (or even weaknesses – being open about them would make the strength that much more convincing) of MAX as the development environment. With many other complex development/design environments, the task of producing such examples is taken up by 3rd parties. Witness Gnomon tutorials for Maya or cmiVFX tutorials for Hounidi (e.g., the one on Procedural Cities), etc., etc. For MAX, such materials are not that readily available.

I am not sure how one can go about it. Maybe people could suggest some interesting/relevant projects that could be build and exhaustively explained by the Cycling people? Or one could commission some expert users to share/annotate their projects for incorporation into tutorials?

If one could see something immediately impressive and have it explained/available for tweaking, the MAX environment would be that much more appealing. The experience of teaching MAX alongside Processing, for example, shows how the availability of many complete and working examples (e.g., via OpenProcessing) is immediately appealing to the students (and educational to all).

Returning to Gen. Apart from seeing what small-grain gains should be possible, I would love to have access to some examples of more complex projects as discussed above. For example: can one build a fast, large-population, multi-threaded agent system using Gen? Can another version of this system be run on GPU, using Gen? Can the new MAX physics be added to it?

Or what can the others suggest?

#213747
Oct 19, 2011 at 11:35pm

@jhdkfj39929 Thanks for your feedback. Great points.

We’ll be continuing to work on documentation and examples. Right now we’re focusing pretty heavily on just getting the software done, but over the next several months we’ll be fleshing out with some of the things you mention.

In the meantime I’d suggest you examine the Projects, Toolbox, Article, and Interview web pages where the type of content you are referring to are more likely to exist than the in application tutorials which are designed to simply communicate functionality. We hope to make it easier for users to share large projects and tutorials (almost all of your mentioned examples above come not from the package developers but the community of users).

Regarding Jitter performance, the use of jit.gl.pix is even faster over CPU jitter objects than any of the gains you’ll witness in MSP. We’ll have more illustrative examples soon, but it’s equally mature to the gen~ audio work. Not many examples however.

Regarding your specific questions:

> can one build a fast, large-population, multi-threaded agent system using Gen?

Yes. Simple example in:

examples/jitter-examples/gen/jit.gen.particles.maxpat

> Can another version of this system be run on GPU, using Gen?

Sort of.

> Can the new MAX physics be added to it?

Not to the gen code itself. The code compiled in Gen cannot interface with outside code. The data can move in and out, and one could build something which ties these different parts together in various ways.

Okay, I’ve got to spend more time developing the software than explaining these things right now, but once we release, I’ll get back to helping explain and answer some of these requests.

-Joshua

#213748
Oct 20, 2011 at 9:58am

Good documentation is a real help, and the Max tradition of help files for everything is really useful.

I think the fastest way for me to really get something is through tutorials, and I hope there will be some gen~ tutorials soon. Tutorials offer a glimpse into someone’s process and reasoning and this really help with the challenge of building from scratch.

#213749
Oct 20, 2011 at 12:09pm

Thanks again. Yes, a more sustained community effort would be good too. Still, things like Processing are free and this is encouraging a sharing culture where whole projects change hands and books with examples follow multi-project themes (cf. The Nature of Code, now that i mentioned agents). In the other communities I mentioned, people pay for tutorials. With MAX neither mode has quite taken off so it seems reasonable that the developers chip in.

“> Can another version of this system be run on GPU, using Gen?

Sort of.”

Not nice to tease people…

#213750
Oct 20, 2011 at 2:38pm

Sorry. Not trying to tease. Just limited time for forums at the moment.

The caveat is that you have to treat your data as pixels currently, and then what do you do with the data to render? Right now you would then need to move the values back to the CPU. There are lots of creative ways to use jit.gl.pix for gpgpu programming.

In the future, we could have an OpenCL backend for other kinds of data types than vec4 on gpu, and other possible utilities.

#213751
Oct 21, 2011 at 1:44pm

thanks Joshua and Andrew for the feedback. I will start small… :)))
looking forward for more examples on how to handle Gen for Jitter (among some other really cool new objects, like Jit.gl.camera, and the improvements in the jit.gl.model).
thanks a lot for this great upgrade in max.

#213752
Oct 21, 2011 at 4:50pm

Hi sandroid,
We’ll be able to roll out a lot more example and tutorial content for Gen post-release. I know I personally am looking forward to making some “Gen Recipes” when I can get a chance. For now, here is something I whipped up the other day using jit.gl.pix. More soon, hopefully.

– Pasted Max Patch, click to expand. –
#213753
Oct 23, 2011 at 9:26am

Hi, does anyone how to use the “for” operator in codebox, and in general whether it is possible to use in jit.gen cycles?

#213754
Oct 23, 2011 at 9:36am

And yet, as you can take submatrix of the matrix, and vice versa submatrix written in a matrix, in the case when the matrix is greater than two dimensions in jit.gen?
I understand “sample” operator works only with two-dimensional matrices?
Thank you very much!)

#213755
Oct 23, 2011 at 9:57am

hi Artur,
for is a reserved word for a future release. Currently, there is no iteration statement (for, while, …) in GenExpr.

As for sample and nearest. These are both N-dimensional operators. You can sample a 3D, 4D, even 32D matrix with it. sample uses linear interpolation so for high dimensional matrices, it will become expensive. For example, a 32D matrix will have 2^32 corners for a sampled location that have to be interpolated.

#213756
Oct 23, 2011 at 11:47am

Excuse me, but when I try to use the 3Dmatrix and “sample” ,max error:
Object – clang, Message – jit method no module to jit,
Object – clang, Message – not jitted,
Object – jit_gen_interface, Message – could not derive constructor from patcher,

Here is an example, that I am doing wrong?

parameters a and b are working, and when the parameter with nothing happening.
Immensely grateful))

Attachments:
  1. example.maxpat
#213757
Oct 23, 2011 at 11:52am

I mean a “c” parameter does not work, that is the third coordinate.

#213758
Oct 23, 2011 at 5:37pm

Thanks for pointing this out. ND sampling is fixed for the next release. It’s not in the Gen document right now, but in jitter gen objects, the binary operators (+, -, /, *, %, etc.) can take vector arguments. For example [+ 1 2 3] will add the input to vec(1, 2, 3). In your patch, I noticed you swizzed out the norm components and add them to your params a, b, and c. You can either pack these params as a vector, say [param offset 0 0 0] or do the following [+ a b c].

– Pasted Max Patch, click to expand. –
#213759
Oct 23, 2011 at 5:59pm

Thank you. So really it is more convenient)))

#213760

You must be logged in to reply to this topic.