memory-alignment Questions

1

Solved

I'm reading Intel manual about Stack Frames. It was noted that The end of the input argument area shall be aligned on a 16 (32, if __m256 is passed on stack) byte boundary. I don't quite und...

3

Solved

I am trying to cast a uint8_t array to uint32_t array. However, when i try to do this, I cant seem to be able to access every consecutive 4 bytes. Let us say I have a uint8_t array with 8 bytes. I...
Mccormac asked 22/10, 2016 at 15:46

4

Solved

I have the following: #include <stdio.h> typedef union u_data { struct { int a; int b; int c; }; int elem[3]; } my_data; int main(void) { my_data data; data.a = 3; data.b = 5; ...
Viviennevivify asked 24/11, 2017 at 10:36

2

Solved

Consider the following C code: #include <stdint.h> void func(void) { uint32_t var = 0; return; } The unoptimized (i.e.: -O0 option) assembly code generated by GCC 4.7.2 for the code abo...
Muskogee asked 21/11, 2017 at 10:45

1

Solved

I have a struct consisting of seven __m256 values, which is stored 32-byte aligned in memory. typedef struct { __m256 xl,xh; __m256 yl,yh; __m256 zl,zh; __m256i co; } bloxset8_t; I achieve t...
Lyre asked 10/11, 2017 at 22:1

3

Solved

Consider the following struct that contains some environment values: struct environment_values { uint16_t humidity; uint16_t temperature; uint16_t charging; }; I would like to add some additi...
Shoddy asked 26/9, 2017 at 11:27

1

Solved

The following apparently valid code produces a misaligned address runtime error using the UndefinedBehaviorSanitizer sanitiser. #include <memory> #include <functional> struct A{ std:...

4

Solved

For any object type T is it always the case that sizeof(T) is at least as large as alignof(T)? Intuitively it seems so, since even when you adjust the alignment of objects like: struct small { cha...
Arbogast asked 27/9, 2017 at 21:23

1

Solved

C++17 introduces std::aligned_alloc and alignment-aware new that can do over-aligned allocations, but what about std::allocator? Does it handle over-aligned types?
Renter asked 25/9, 2017 at 7:16

2

Solved

Is there a portable way that only relies on what the C99 standard provides to find out the maximum required alignment that is needed for any data type. Like maxalign_t in C++11. What I'm currentl...
Inept asked 8/7, 2016 at 16:4

1

Solved

I defined the following variables in the .data section in NASM: section .data var1 DD 12345 ; int (4 bytes) var2 DB 'A' ; char (1 byte) padding1 DB 123 ; 1 byte padding padding2 DB 123 ; 1 b...
Hanshaw asked 25/8, 2017 at 4:10

6

Solved

What is the difference between aligned and unaligned memory access? I work on an TMS320C64x DSP, and I want to use the intrinsic functions (C functions for assembly instructions) and it has usho...
Sergio asked 30/6, 2009 at 13:53

4

Solved

I am working on a single producer single consumer ring buffer implementation.I have two requirements: Align a single heap allocated instance of a ring buffer to a cache line. Align a field within ...
Byrle asked 26/12, 2013 at 21:21

1

Solved

I have a data structure that needs to be 4-KiB aligned. I can enforce this using __attribute__ ((aligned (4096))). The problem is that this alignment requirement causes memory to be wasted. This i...
Gerdi asked 16/7, 2017 at 12:39

1

Solved

How to reconcile short conditional jumps with branch target alignments in Delphi assembler? I’m using Delphi version 10.2 Tokyo, for 32-bit and 64-bit assembly, to write some functions entirely us...
Railing asked 14/7, 2017 at 21:49

1

Solved

Here is a memory layout within a custom allocator :- ^ toward less address .... Header [size=16 alignment=4 ] ....(1) some waste space A [size=A (unknown) ] content [size="SIZE" alignment="ALIGN"]...
Bruise asked 9/7, 2017 at 8:2

1

Quoted from https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html: -falign-labels -falign-labels=n Align all branch targets to a power-of-two boundary, skipping up to n bytes like -falign...
Anthropometry asked 8/7, 2017 at 20:7

1

According to the Intel® 64 and IA-32 Architectures Optimization Reference Manual, section B.4 ("Performance Tuning Techniques for Intel® Microarchitecture Code Name Sandy Bridge"), subsec...
Nevels asked 16/6, 2017 at 9:59

4

Solved

So I read that when variables are declared in c++ if you want to get the optimum cache reads the memory should stick to its natural alignment. Example: int a; // memory address should end in 0x0,0...
Encyclopedic asked 6/7, 2015 at 21:45

1

In my C code I have complex float M[n][n]; complex float *delta = malloc(n * sizeof *delta); complex float *v = malloc(n * sizeof *v); for (i = 0; i < n; i++) { v[i] -= 2.*delta[j]*M[j][i]; } ...
Xenos asked 14/1, 2017 at 9:43

1

Solved

I know structure packing is a common thing in C++ programming (at least on low memory systems). But what about classes. I know it works because I tried it #include <iostream> #pragma pack(p...
Unquestioned asked 31/5, 2017 at 14:8

2

Solved

I tried to measure the size of a struct and its fields (Playground): use std::mem; struct MyStruct { foo: u8, bar: char, } println!("MyStruct: {}", mem::size_of::<MyStruct>()); let obj ...
Rain asked 28/4, 2017 at 9:37

1

Solved

Here's some code which GCC 6 and 7 fail to optimize when using std::array: #include <array> static constexpr size_t my_elements = 8; class Foo { public: #ifdef C_ARRAY typedef double Vec[...
Respire asked 27/4, 2017 at 8:0

2

Solved

I am reading a book on pointers named "understanding and using c pointers" When it comes to void * it says It has two interesting properties: A pointer to void will have the same represent...
Tobias asked 29/3, 2017 at 11:18

1

Solved

I'm reading a bit about alignment in C++, and I am not sure why the alignment of a class that contains solely a char array member is not the sizeof of the array, but turns out to be always 1. For e...
Phytobiology asked 1/3, 2017 at 5:24

© 2022 - 2024 — McMap. All rights reserved.