Похоже, что ваша структура dict выглядит примерно так:
fieldData['PORTFOLIO_MPOSITION'] =
{'PORTFOLIO_MPOSITION' : {'Security': 'OPTYWHKS Curncy', 'Position': 1.0}}
, и в этом случае вам потребуется доступ к «Security», например:
fieldData['PORTFOLIO_MPOSITION']['PORTFOLIO_MPOSITION']['Security']
, чтобы иметь возможность получить к нему доступ. с fieldData ['PORTFOLIO_MPOSITION'] ['Security'], когда вы вводите fieldData ['PORTFOLIO_MPOSITION'] на консоли, оно должно выглядеть примерно так:
{'Security': 'OPTYWHKS Curncy', 'Position': 1.0}
Я не уверен, что понимаю, зачем тебе нужно что-то особенное. Любой традиционный PRNG должен портировать более или менее напрямую. Линейная конгруэнтная должна работать нормально. У вас есть какие-то особые свойства, которые вы пытаетесь установить?
Есть пакет MDGPU (GPL), который включает реализацию функции GNU rand48 () для CUDA здесь .
Я нашел это (довольно легко, используя Google , который, я полагаю, вы пробовали :-) на форумах NVidia здесь .
Я не нашел хорошего генератора параллельных чисел для CUDA, однако я нашел параллельный генератор случайных чисел, основанный на академических исследованиях здесь: http: //sprng.cs.fsu .edu /
Depending on your application you should be wary of using LCGs without considering whether the streams (one stream per thread) will overlap. You could implement a leapfrog with LCG, but then you would need to have a sufficiently long period LCG to ensure that the sequence doesn't repeat.
An example leapfrog could be:
template <typename ValueType>
__device__ void leapfrog(unsigned long &a, unsigned long &c, int leap)
{
unsigned long an = a;
for (int i = 1 ; i < leap ; i++)
an *= a;
c = c * ((an - 1) / (a - 1));
a = an;
}
template <typename ValueType>
__device__ ValueType quickrand(unsigned long &seed, const unsigned long a, const unsigned long c)
{
seed = seed * a;
return seed;
}
template <typename ValueType>
__global__ void mykernel(
unsigned long *d_seeds)
{
// RNG parameters
unsigned long a = 1664525L;
unsigned long c = 1013904223L;
unsigned long ainit = a;
unsigned long cinit = c;
unsigned long seed;
// Generate local seed
seed = d_seeds[bid];
leapfrog<ValueType>(ainit, cinit, tid);
quickrand<ValueType>(seed, ainit, cinit);
leapfrog<ValueType>(a, c, blockDim.x);
...
}
But then the period of that generator is probably insufficient in most cases.
To be honest, I'd look at using a third party library such as NAG. There are some batch generators in the SDK too, but that's probably not what you're looking for in this case.
EDIT
Since this just got up-voted, I figure it's worth updating to mention that cuRAND, as mentioned by more recent answers to this question, is available and provides a number of generators and distributions. That's definitely the easiest place to start.