i’m working with supercomputer, using MPI.
but problem in.. C++
have a program, which open file with data and read it into vector<long>v1
//open file
...
vector<long>v1;
while (!f1.eof()){
//input data into
v1.push_back(s1);
}
okey, when file of data contains only 50 millions of “long-numbers”, it worked perfect.
but when file of data contains over 75 millions of “long-numbers”, it failed with exception:
std::bad_alloc();
how to improve this?
besides, use many processors ( over 100 )
Don’t use a vector for this. A vector requires all its elements to fit in consecutive memory locations and it isn’t suitable for very large collections. The right data structure to use depends on your access patterns,
listwill work, but it will waste a lot of memory (two pointers for eachlongyou store). Perhaps you want to break thelongs into groups of 100 or so and make a linked list of those groups. Again, the right answer depends on your actual outer problem.