memory-alignment Questions
3
I am writing a tool to port games written in C/C++ from the 24bit eZ80 to Windows/Linux. One of the issues is that int24_t doesn't exist on x86/x64.
typedef uint32_t uint24_t doesn't always work, e...
Mirepoix asked 18/6 at 1:47
1
I narrowed down a problem in my GUI code to SetWindowTextW(HWND, wchar_t *) silently failing if the new window title is not aligned to two bytes. In this case, SetWindowText() returns 1 (success) b...
Saury asked 5/2 at 21:9
1
Solved
Data is usually aligned with its own data type, i.e a 32-bit int is usually aligned to 4 bytes, this makes loading/storing them more efficient for the processor.
Now when does cache line alignment ...
Swearword asked 31/7, 2023 at 15:43
3
I've used C pointers for some time now and everything has always worked as expected. However now I've run into the ISO standard that says "If the resulting pointer is not correctly aligned for...
Centesimo asked 25/7, 2023 at 15:33
3
Solved
I need to allocate large regions of memory (megabytes) with large alignments (also potentially in the megabyte range). The VirtualAlloc family of functions don't seem to provide options to do this....
Cowardly asked 30/9, 2011 at 22:33
3
Solved
Is there an attribute to enforce padding after a variable?
I have a volatile (non-cached) variable declared as such:
volatile int foo __attribute__((aligned(CACHE_LINE_SIZE));
I would like to prev...
Hemicellulose asked 22/5, 2023 at 8:26
1
Recently, I was made aware of the potential issues of memory alignment for Fixed-size vectorizable Eigen objects.
The correct code as stated in the doc:
class Foo
{
...
Eigen::Vector2d v;
...
pu...
Hyatt asked 2/8, 2020 at 12:48
3
Solved
How does stack alignment work in ASMx64? When do you need to align the stack before a function call and how much do you need to subtract?
I didn't understand what was the purpose of it. I know ther...
Magnetohydrodynamics asked 7/11, 2020 at 15:0
3
Solved
I have an object that has an address that is not 4-byte aligned. This causes a HardFault error in the cpu when there is a STR instruction saving 2 registers.
This is the generated code:
00000000 &...
Zelikow asked 16/8, 2013 at 8:39
1
Solved
The _mm_load_ps() SSE intrinsic is defined as aligned, throwing exception if the address is not aligned. However, it seems visual studio generates unaligned read instead.
Since not all compilers a...
Sipper asked 15/5, 2020 at 9:32
4
I know this is a weird question to ask in Java,
but is there a way to let Java dynamic memory allocation be aligned with some alignment constraints?
For example, is it possible to dynamically alloc...
Slate asked 11/3, 2011 at 1:46
8
Solved
If I want to process data in a std::vector with SSE, I need 16 byte alignment. How can I achieve that? Do I need to write my own allocator? Or does the default allocator already align to 16 byte bo...
Peal asked 10/12, 2011 at 11:38
7
Solved
following excerpted from here
pw = (widget *)malloc(sizeof(widget));
allocates raw storage. Indeed, the malloc call allocates storage
that's big enough and suitably aligned to hold an object...
Yasukoyataghan asked 6/1, 2012 at 2:5
1
Solved
I just saw that C++23 plans to deprecate both std::aligned_storage and std::aligned_storage_t as well as std::aligned_union and std::aligned_union_t.
Placement new'd objects in aligned storage are ...
Cholecystectomy asked 11/4, 2022 at 12:59
4
Solved
Similar to what I've learned in C++, I believe it's the padding that causes a difference in the size of instances of both structs.
type Foo struct {
w byte //1 byte
x byte //1 byte
y uint64 //...
Cohen asked 21/8, 2016 at 11:10
2
The following question is related, however answers are old, and comment from user Marc Glisse suggests there are new approaches since C++17 to this problem that might not be adequately discussed.
...
Loveinidleness asked 11/2, 2020 at 13:19
3
Solved
I'm taking this course, and I'm really struggling understanding the directive .align concept.
Here's an example, which I couldn't understand:
I know that inside the data segment, there are address...
Jeroldjeroma asked 26/10, 2013 at 16:9
4
What is the meaning of align an the start of a section?
For example:
align 4
a: dw 0
How does it save memory access?
Pulpy asked 30/6, 2012 at 21:3
0
Due to the 16 bytes alignment by default, does this imply the assertion in my question ?
Cadent asked 2/12, 2021 at 1:9
0
env : x86-64; linux-centos; 8-cpu-core
For testing 'false sharing performance' I wrote c++ code like this:
volatile int32_t a;
volatile int32_t b;
int64_t p1[7];
volatile int64_t c;
int64_t p...
Sanity asked 8/11, 2021 at 7:17
1
I'm trying to understand why a struct that contains only int takes 8 bytes of memory inside a class.
considering the following code;
static void Main()
{
var rand = new Random();
var twoIntStruc...
Boyer asked 19/10, 2021 at 13:10
1
Solved
I may be misunderstanding how cache fetches work, but I'm curious if there are any compiler optimizations for aligning small functions that are not inlined.
If the cache-line-size is 64 bytes on a ...
Alkalosis asked 27/9, 2021 at 0:2
4
Solved
Is it possible to make std::vector of custom structs allocate aligned memory for further processing with SIMD instructions? If it is possible to do with Allocator, does anyone happen to have such a...
Intertwist asked 17/10, 2012 at 20:9
5
Solved
I work with shared memory right now.
I can't understand alignof and alignas.
cppreference is unclear : alignof returns "alignment" but what is "alignment" ? number of bytes to add for the next bl...
Dextrality asked 13/6, 2013 at 15:44
0
64 bit architecture like x86-64 have word size of 64bits. In this case, if a memory access crosses over the word boundary, then it will require double the time to access data. So alignment is requi...
Ashby asked 10/7, 2021 at 6:2
1 Next >
© 2022 - 2024 — McMap. All rights reserved.