I want to create array for huge amount of data (eg. ints).
This array will be representation of 2D matrix.
I cannot use STL as it will be run with CUDA.
I'm wondering what are the pros and cons of following options:
- int arr[SIZE] - this is the simplest way to create an array. It's allocated on stack so it will be the fastest one - the problem here is that has very limited size.
- int* arr = new int[SIZE]
- int** arr = new int*[DIM1] - that's the worst case if we look on efficiency, but it allows to store INT_MAX * INT_MAX values.
I was considering second option. Sizeof(int) on my computer is 32 bits. I think that it may be too small for some test cases (if I use matrices bigger than 32k x 32k).
The third option seems to be the most flexible, but I heard that's not the good practice.
Is there another option for creating arrays like that ( > 1B elements)? Is it possible to create one dimensional array with bigger than INT_MAX/2 length?