Skip to content

Function scopes in Cuda #774

Answered by Robadob
isolin asked this question in Q&A
Jan 30, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

DeviceApi is a templated object. So you would either need to define the function as a template itself.

e.g.

template<typename MessageIn, typename MessageOut>
float rndRange(flamegpu::DeviceAPI<MessageIn, MessageOut> *FLAMEGPU, float min, float max) {
    return FLAMEGPU->random.uniform<float>() * (max - min) + min;
}

Or specify the matching template arguments.

e.g.:

float rndRange(flamegpu::DeviceAPI<flamegpu::MessageNone, flamegpu::MessageBruteForce> *FLAMEGPU, float min, float max) {
    return FLAMEGPU->random.uniform<float>() * (max - min) + min;
}

This definitely isn't simple for users unfamilar with C++, we will need to have a good think about how can improve this (however the heavy…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@isolin
Comment options

Answer selected by isolin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants