- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm usign large array of very small random numbers, often between 0 and 10. This large arrays consume 4 bytes per entry (int), and I would like to know if there is a way for generating arrays of short int and chars to save memory.
Thanks in advance for your help,
Daro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately there is no 8-bit or 16-bit variant of the uniform RNG in MKL. The only workaround that I see is to generate the data by portions as 32-bit integers and process those integers in a way you need. It will save the storage.
If for some reason youneed to store entire array of chars you still can generate it by blocks by converting each block into array of bytes, something like this:
#define N (1024*1000)
#define BLOCK_SIZE 1024
int block[BLOCK_SIZE];
char urng
... //Create the random stream
for (i=0; i
{
// Generate block of 32-bit integers
viRndUniform(0, stream, BLOCK_SIZE, block, 0, 10);
for (j=0; j
{
urng[i+j] = (char)block
}
}
... // Delete the random stream
That may help,
Regards,
Sergey
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately there is no 8-bit or 16-bit variant of the uniform RNG in MKL. The only workaround that I see is to generate the data by portions as 32-bit integers and process those integers in a way you need. It will save the storage.
If for some reason youneed to store entire array of chars you still can generate it by blocks by converting each block into array of bytes, something like this:
#define N (1024*1000)
#define BLOCK_SIZE 1024
int block[BLOCK_SIZE];
char urng
... //Create the random stream
for (i=0; i
{
// Generate block of 32-bit integers
viRndUniform(0, stream, BLOCK_SIZE, block, 0, 10);
for (j=0; j
{
urng[i+j] = (char)block
}
}
... // Delete the random stream
That may help,
Regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sergey,
Thanks. The idea of blocking seems very good. I'll implement it and see the effect on memory and performance.
Best regards,
Daro
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page