Skip to content

Memory Layout of CompMatr in v4 #540

Closed Answered by TysonRayJones
eessmann asked this question in Q&A
Discussion options

You must be logged in to vote

Currently

Currently no. While the GPU memory is flat, the CPU memory is allocated as non-contiguous mallocs here:

qcomp** cpu_allocMatrix(qindex dim) {

    // TODO:
    // the design of storing the CPU matrix elements as a 2D structure will impede
    // performance for many qubits; the allocated heap memories for each row
    // have no gaurantee to reside near other, so that their access/iteration in
    // hot loops may incur unnecessary caching penalties. Consider storing the
    // elements as a flat array, like we do for the GPU memory. This makes manual
    // modification by the user trivially harder (changing [r][c] to [r*n+c]),
    // but should improve caching, and significant…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TysonRayJones
Comment options

@eessmann
Comment options

Answer selected by eessmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants