Hacker News new | past | comments | ask | show | jobs | submit login

Instead of markers, I like to use typedefs instead. Here's an example how this would look like in a HPC related program. Basically, if you know Fortran, you know where this is coming from.

    typedef const double * const __restrict__ IN;
    typedef double * const __restrict__ OUT;
    typedef const int INT_VALUE;
    typedef const double FP_VALUE;

    void diffuse_c(
        OUT runtime_total_s,
        OUT runtime_boundary_s,
        OUT thermal_energy_updated,
        IN thermal_energy,
        INT_VALUE nx,
        INT_VALUE ny,
        INT_VALUE nz
    );



I can't be the only one who finds "INT_VALUE" both superfluous and unnecessarily ugly?


You're right, I have been thinking about this naming as well. I think in this context, "INT_PARAM" would be better. I like to typedef it because this way it's easier to replace with a hardware specific integer type later on if I decide to do so. Anyways, the "VALUE" naming is coming from Fortran, which is by default pass-by-reference, so you use it to get pass-by-value.

Edit: Thinking about it some more, "INT_VALUE" still makes sense - it makes it clear that this specific symbol should be accessed as a value, not as a pointer. Doing this reminds me that I'm (probably) imposing more register pressure by passing by value. In general I'd probably pass a const int * const pointer here, but in this specific case I needed values because of some CUDA specific limitation.


> Doing this reminds me that I'm (probably) imposing more register pressure by passing by value.

Not for "int"s, I would be very surprised if sizeof(int*) < sizeof(int) on your system.


Good point, that was a bit of a brainfart of mine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: