Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Monday, 27 January 2025 at 05:53:09 UTC, John C. wrote: Print out the pointer to `a[0]` to verify what the actual alignment is. If we look to output above, first line addresses are aligned to 32 bytes Except address with B(1011) at second from the right position?

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 16:43:19 UTC, Johan wrote: The `align(32)` applies to the slice `a`, not the contents of `a` (where `a` points to). Thank you, seems that it is reason for that errors. I remember that dynamic array can be represented as structure with size_t len and pointer to me

Re: Obtaining an address given a (run time) variable name

2025-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 26, 2025 4:41:53 PM MST DLearner via Digitalmars-d-learn wrote: > On Monday, 20 January 2025 at 19:54:19 UTC, Jonathan M Davis > wrote: > [...] > > Also, there's really no reason to be doing anything with char[] > > instead of string unless you're specifically planning on > > mu

Re: Obtaining an address given a (run time) variable name

2025-01-26 Thread DLearner via Digitalmars-d-learn
On Monday, 20 January 2025 at 19:54:19 UTC, Jonathan M Davis wrote: [...] Also, there's really no reason to be doing anything with char[] instead of string unless you're specifically planning on mutating the elements in your string, and casting from a string literal to a char[] is almost never

Re: Counting at compile-time

2025-01-26 Thread monkyyy via Digitalmars-d-learn
On Sunday, 26 January 2025 at 15:42:44 UTC, DLearner wrote: Suppose we have ``` enum Count = 0; static if () ... enum Count = Count + 1; // is disallowed else static if () ... enum Count = Count + 1; // is disallowed else ``` and the objective is to determine (at compile time) th

Re: Counting at compile-time

2025-01-26 Thread DLearner via Digitalmars-d-learn
On Sunday, 26 January 2025 at 16:43:23 UTC, Bradley Chatha wrote: On Sunday, 26 January 2025 at 15:42:44 UTC, DLearner wrote: But how to get that value into Count? It's hard to say what would exactly fit your use case since this is just a minimal example, so it's hard to gauge what other res

Re: Counting at compile-time

2025-01-26 Thread Bradley Chatha via Digitalmars-d-learn
On Sunday, 26 January 2025 at 15:42:44 UTC, DLearner wrote: But how to get that value into Count? It's hard to say what would exactly fit your use case since this is just a minimal example, so it's hard to gauge what other restrictions and inputs exists, but if your logic is a bit more compl

Re: core.simd and dynamic arrays

2025-01-26 Thread Johan via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:45:11 UTC, John C. wrote: Hello everyone. I am complete newbie in D and programming at all and I can't understand why dynamic arrays can't be used within following D code: ```d import std.random : uniform01; import core.simd; void main() { align(32) float[]

Counting at compile-time

2025-01-26 Thread DLearner via Digitalmars-d-learn
Suppose we have ``` enum Count = 0; static if () ... enum Count = Count + 1; // is disallowed else static if () ... enum Count = Count + 1; // is disallowed else ``` and the objective is to determine (at compile time) the number of times cond-1 or cond-2 is triggered (perhaps for

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 13:59:09 UTC, John C. wrote: I have tested this code with LDC on run.dlang.io, segmentation fault does occur only if -mattr=+avx is used. Without this flag no errors are produced. Actually, if I use -mcpu=avx with DMD, no error is generated. However, if this flag

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:45:11 UTC, John C. wrote: I'm using LDC compiler 1.36.0 on x86_64 Linux system with "-w -O3 -mattr=+avx" compiler flags. I have tested this code with LDC on run.dlang.io, segmentation fault does occur only if -mattr=+avx is used. Without this flag no errors ar

Re: core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:56:55 UTC, ryuukk_ wrote: LDC 1.36 = 1 years old latest version is LDC 1.40 with LDC 1.40, your code works on my computer now my turn to ask a question: why were you using a 1 years old compiler version? common sense would be to make sure you are up to dat

Re: core.simd and dynamic arrays

2025-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:56:55 UTC, ryuukk_ wrote: common sense would be to make sure you are up to date before wondering why it's broken This is the learn forum. People are learning here. Try to be nicer, there is no need for this. -Steve

Re: identify literals

2025-01-26 Thread Dom DiSc via Digitalmars-d-learn
On Friday, 24 January 2025 at 19:12:59 UTC, monkyyy wrote: On Friday, 24 January 2025 at 10:50:15 UTC, Dom DiSc wrote: do they have some other, more specific property? complete solutions: probably not, partial solutions well ```d import std; bool isctfe(alias i)(){ bool _isctfe

Re: core.simd and dynamic arrays

2025-01-26 Thread ryuukk_ via Digitalmars-d-learn
LDC 1.36 = 1 years old latest version is LDC 1.40 with LDC 1.40, your code works on my computer now my turn to ask a question: why were you using a 1 years old compiler version? common sense would be to make sure you are up to date before wondering why it's broken

core.simd and dynamic arrays

2025-01-26 Thread John C. via Digitalmars-d-learn
Hello everyone. I am complete newbie in D and programming at all and I can't understand why dynamic arrays can't be used within following D code: ```d import std.random : uniform01; import core.simd; void main() { align(32) float[] a = new float[128]; align(32) float[] b = new float[128