I have some code that uses a std::array. This is using the stack to allocate the memory. But I need to create an array of around 2MB. So doing some searching it seems that I can use std::vector that uses the heap.
I modified my code to do that
//alignas(128) std::array<uint32_t, array_size> write_data;
//alignas(128) std::array<uint32_t, array_size> read_data = { { 0 } };
alignas(128) std::vector<uint32_t> write_data[array_size];
alignas(128) std::vector<uint32_t> read_data[array_size];
But I am now getting error on other parts of the code. This uses some threads
std::thread read_thread(read, std::ref(dev),
(void*)read_data.data(), read_data.size() * sizeof(uint32_t), dma_block_size*32);
std::thread write_thread(write, std::ref(dev),
(void*)write_data.data(), write_data.size() * sizeof(uint32_t), num_dma_blocks);
E0289 no instance of constructor "std::thread::thread" matches the argument list
E0153 expression must have class type
The problem is on the read/write and read_data/write_data in the code above. Could someone tell me what the issue is as I am not really a cpp programmer. Thanks