11 votes
Accepted

Memory Management - Why certain initializations order are faster?

Such an effect happens because of how the data of the int** a is stored in memory (as per C/C++). This question on StackOverflow has answers with some more details (...
Anton Menshov's user avatar
  • 8,602
6 votes
Accepted

Inefficient comparisons of custom data type C++

Why not this, which avoids the inequality comparison before the less-than altogether: ...
Wolfgang Bangerth's user avatar
4 votes
Accepted

Efficient way to store array where elements are added and removed frequently

Let me start with the following: Even very good and experienced programmers have a very hard time estimating whether a particular piece of code is performance critical or not. This has given rise to ...
Wolfgang Bangerth's user avatar
4 votes

How to store a TB size array in C++ on a cluster

You could try using UPC++, which sets up a globally accessible address space distributed across your nodes. A more standard approach would be to learn how to use MPI.
Richard's user avatar
  • 3,921
4 votes
Accepted

Space complexity of a semidefinite program

For a problem with $m$ linear equality constraints and a $n$ by $n$ matrix variable, the problem data $A$, $b$, $C$ requires $O(mn^{2})$ storage for $A$, $O(m)$ storage for $b$, and $O(n^{2})$ storage ...
Brian Borchers's user avatar
3 votes
Accepted

Memory issues with iterative solvers

As you pointed out, your matrices are sparse which means that the number of non-zeros is small compared to the number of zeros. There are several formats to store such matrices, e.g. COO, CSC, CSR etc....
vydesaster's user avatar
3 votes

How can we solve the normal equations with limited memory?

That might also have been a trick question. Let's say you want to solve the normal equations for $Ax=b$, i.e., $(A^T A) x = A^T b$. Let's assume for a moment that the questioner meant that $A$ is ...
Wolfgang Bangerth's user avatar
3 votes

Inefficient comparisons of custom data type C++

Wolfgang's answer is probably the best one, because its almost guaranteed to not screw up in unpredictable ways, and the intent couldn't be more clear. That said... If the 8 bit integers are unsigned, ...
Charlie S's user avatar
  • 661
3 votes

Methods to improve the efficiency and the memory requirement of LU factorization for complex symmetric system matrix

You probably want a factorization of the form $\mathbf A = \mathbf L \mathbf D \mathbf L^T$, it can certainly be applied to a complex symmetric $\mathbf A$. LAPACK implements this factorization within ...
rchilton1980's user avatar
  • 4,822
3 votes

Memory Management - Why certain initializations order are faster?

Noting correctly that this is an array of pointers to arrays of ints: In the first version, the code is accessing element 0 of each successive array of ints, then element 1, etc. That means it is ...
PMar's user avatar
  • 31
3 votes

Access optimized data structure for representing integer lattice

In essence, you are asking whether you can enumerate the integer lattice sites within your domain from $1$ to $N$ in such a way that accessing the east/west/north/south neighbors of a location $n$ ...
Wolfgang Bangerth's user avatar
2 votes
Accepted

Reordering algorithm for minimization of ram usage of a skyline matrix

For direct solution in 3D, you should probably be using some flavor of nested dissection (ND) or minimum degree (MD). These attack the storage requirements of A=LL' factorization directly, not the ...
rchilton1980's user avatar
  • 4,822
2 votes
Accepted

Why does multithreaded code Segfault in 64-bit but not 32-bit

It's impossible to tell without knowing the code you are using. But fortunately, segmentation faults are easy to debug: basically, a segfault means that you are accessing memory you should not access, ...
Wolfgang Bangerth's user avatar
2 votes
Accepted

Why does PETSc matrix memory allocation improve performance so much?

Warning: this answer is only going to give a brief overview, for the real details, the one source that won't be wrong is the source code. The core matrix AIJ format is basically the same as the one ...
origimbo's user avatar
  • 2,229
2 votes
Accepted

Use of GPU with respect to CPU

Unfortunately, GPUs will be of no help to you in this particular situation. Your problem is in the memory limitation; thus, you just do not have enough RAM resources to allocate/factorize/solve the ...
Anton Menshov's user avatar
  • 8,602
2 votes

How to store a TB size array in C++ on a cluster

Really the only way to run simulations on a multi-node cluster is to use MPI. And you don't distribute data because that would mean it would start out in one place. With MPI everything is distributed ...
Victor Eijkhout's user avatar
2 votes

How to compute Singular value decomposition of a large matrix with Python

Did you try with Dask ? https://examples.dask.org/machine-learning/svd.html You can manage very large matrices. There is also a nice blog post about it https://blog.dask.org/2020/05/13/large-svds
user1164's user avatar
2 votes

Access optimized data structure for representing integer lattice

You can probably speed things up a little bit by storing the array in 4x4 square subarrays so that each of them fit in cache line (64 bytes = 4x4 32-bit integers). This changes the probability ...
Ark-kun's user avatar
  • 131
2 votes

Inefficient comparisons of custom data type C++

I think it would be faster to assemble a 32-bits integer for each operands and compare them, as you initially intended. It will be equivalent to what you did "by hand". If numbers stored in ...
BrunoLevy's user avatar
  • 2,305
1 vote

How can we solve the normal equations with limited memory?

Among approximate techniques: Gradient descent should do a decent job, given the limitations. Randomized SVD is an effective technique. It is quick to implement, and there are ready-to-use error ...
Federico Poloni's user avatar
1 vote

How can we solve the normal equations with limited memory?

So called “matrix free” methods, relying primarily on the ability to perform multiplication of the matrix by a vector, lend themselves nicely to iterative techniques such as GMRES. The matrix itself ...
A rural reader's user avatar
1 vote
Accepted

Understading memory sharing in a GPGPU using a lattice example

The GPU consists of several streaming multiprocessors. Each SM has 64-96kB of shared memory that can be accessed by up to 1024-2048 threads. This shared memory allows these threads to communicate. To ...
Richard's user avatar
  • 3,921
1 vote

Doing computations on a very large numpy array: streaming the calculation vs out-of-core memory

A lot of this will depend on the details of your do_big_calculation function. In general you want to avoid pushing data to disk for performance reasons. Disk I/O ...
Michael Anderson's user avatar
1 vote
Accepted

Minimizing the used memory in diffusion simulation using Python

It seems that you are going from one extreme to the other: you probably want to generate all $N$ particles at once without the for-loop; however, you don't want to generate all the ...
Anton Menshov's user avatar
  • 8,602
1 vote

Finite difference - Explicit / Implicit / Crank Nicolson - Does the implicit method require the least memory?

You seem to have given the 1D equations for the discretizations, even though the problem is in 2D. Regardless, the explicit method requires the least memory since you don't even have to form a ...
Savithru's user avatar
  • 343
1 vote
Accepted

Compare 64gb dd3 ram with 2gb Quadro M1000M gpu on Lenovo P50

In my opinion there is not a memory type better than other. Simply they are different things. Normal ram are used only by the cpu, and the gpu ram is used onnly by the gpu. This is quite clear when ...
Mauro Vanzetto's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible