473,499 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bus error on vector resize

Hi,

I'm having a problem resizing a (very big) nested vector. It's not the
most streamlined piece of code ever but I need this array to avoid
having to recalculate the same quantity millions of times!

The (relevant) snippets of code are below : since it's relevant though
L=28,T=96 (so TasteProps weighs in at a hefty
8*96*28*28*28*96=1,618,477,056 doubles [which I think requires 12G of
memory - I'm running on an 8GB machine : the problem??])

Can anyone suggest a more elegant solution? If inline calculation is
ruled out I'll have to resort to a lookup file rather than lookup in
memory - something I'd rather not have to deal with as I could quickly
fill up our departments home drive space!).

namespace PropLTable
{
vector< vector< vector< vector< double > > > > ScalarDisc(L),
VectorDisc(L), AxialDisc(L),
k2_lup(L);
vector<vector<vector<vector<vector<vector<double> > > > > >
TasteProps(8);
}

void resizenamespace()
{
using namespace PropLTable;

for (int i=0;i<L;i++)
{
ScalarDisc[i].resize(L);
VectorDisc[i].resize(L);
AxialDisc[i].resize(L);
k2_lup[i].resize(L);
for (int j = 0;j<L;i++)
{
ScalarDisc[i][j].resize(L);
VectorDisc[i][j].resize(L);
AxialDisc[i][j].resize(L);
k2_lup[i][j].resize(L);
for (int k = 0;k<L;k++)
{
ScalarDisc[i][j][k].resize(T);
VectorDisc[i][j][k].resize(T);
AxialDisc[i][j][k].resize(T);
k2_lup[i][j][k].resize(T);
}
}
}

for (int i = 0;i<8;i++)
{
TasteProps[i].resize(T);
for (int j = 0;j<T;j++)
{
TasteProps[i][j].resize(L);
for (int k = 0;k<L;k++)
{
TasteProps[i][j][k].resize(L);
for (int l = 0;l<L;l++)
{
TasteProps[i][j][k][l].resize(L);
for (int m = 0;m<L;m++)
{
TasteProps[i][j][k][l][m].resize(T);
}
}
}
}
}

}

May 7 '06 #1
2 2639
<mr**********************@googlemail.com> wrote in message
news:11********************@i39g2000cwa.googlegrou ps.com...
: I'm having a problem resizing a (very big) nested vector. It's not the
: most streamlined piece of code ever but I need this array to avoid
: having to recalculate the same quantity millions of times!
:
: The (relevant) snippets of code are below : since it's relevant though
: L=28,T=96 (so TasteProps weighs in at a hefty
: 8*96*28*28*28*96=1,618,477,056 doubles [which I think requires 12G of
: memory - I'm running on an 8GB machine : the problem??])
Well yes, this might well be !

: Can anyone suggest a more elegant solution?

Do you really need to keep a cache of 1.6 billion results ??
What is this application where pre-computing all this data
at startup helps performance?
[ if it is not precomputed at startup, then it is stored in
a file, and you'd better read that file in chunks than
stored in all in a hierarchy of vectors ]

There usually are smarter caching schemes, especially if some
computations are performed repeatedly.
Like some kind of mapping of input->output pairs for the most
recent inputs received.

Then if you really were to need such a big cache, it will be
more efficient to allocate a single contiguous vector of data,
and do the index calculations yourself within that big table.

hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
May 7 '06 #2
Hi,

It's for a theoretical physics calculation - the TasteProps array
stores some propagators which are stored for different momenta on the
lattice (this leads to the T*L*L*L*T factor). In the work I do there
are mass splittings into 16 different 'tastes' which can be categorised
into 8 different groups, hence the 8.

I could remove a factor of 8 by calculating the sums earlier, and
reusing the TLLLT array over and over again. In fact, come to think of
it I can completely remove each of the 8 tastes into separate programs
which output them into files, then the overall total can just be read
back into the core - having them separately allows me to analyse their
relative contributions anyway.

Thanks for your help anyway - I'll print that bit out for future
reference as I'm sure I'll run into very similar problems very soon!
Thanks,
Chris

May 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3380
by: Peter Mrosek | last post by:
Hello, I have the following declaration in an header file (abbreviated version): typedef struct { unsigned char rgbBlue; unsigned char rgbGreen; unsigned char rgbRed; unsigned char...
9
2999
by: Alex Vinokur | last post by:
--------- #include <vector> using namespace std; struct Foo { Foo (int) {} }; int main () { vector<Foo> v1;
2
3422
by: mj | last post by:
Hi, I recently have found it necessary to move from fortran to c++ for scientific programming... I'm working on a program that needs to resize a 2d vector of vectors within a function... This...
3
2450
by: leeps_my | last post by:
I'm thinking of using "resize-to-size" to do the trimming: aVector.resize( aVector.size( ) ); I'm wondering why Scott Meyers was recommending "swap trick" instead, since the trick involves...
35
4140
by: imutate | last post by:
I get a bus (or is it buss) error when I resize a vector typedef std::vector<doubledblvec; n = 127; dblvec rv; rv.resize(n); // error happens here Any clues ? I can post more info if...
17
11875
by: toton | last post by:
Hi, I am using a vector to reserve certain amount of memory, and reuse it for new set of data, to avoid reallocation of memory. so the call is something like vector<my_datav;///the temporary...
2
1969
by: nikiplos | last post by:
Hi, all... I have a problem when trying to reallocate a vector for a second time inside a loop. The order is somelike: for (n=k; n<L; n++) { vector.resize(n, (long) 0); ... ...
8
1266
by: kathy | last post by:
I try to use: std::vector <std::vector <std::vector <int>>>; But it seems not work. how many layer the vector can be? for example:
23
3435
by: Mike -- Email Ignored | last post by:
In std::vector, is reserve or resize required? On: Linux mbrc32 2.6.22.1-41.fc7 #1 SMP Fri Jul 27 18:10:34 EDT 2007 i686 athlon i386 GNU/Linux Using: g++ (GCC) 4.1.2 20070502 (Red Hat...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.