Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:43:45 UTC, Siarhei Siamashka wrote: Looks like you forgot to increment the pointer and need "*d++ = cast(ubyte) c;" there. hahaha yup. And filling the buffer one byte at a time is likely slow. prolly but meh, that's where the intrinsics are nice.

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:36:21 UTC, Adam D Ruppe wrote: Oh I should have checked my impl, where I did all this already! https://github.com/adamdruppe/webassembly/blob/master/arsd-webassembly/object.d#L263 Looks like you forgot to increment the pointer and need "*d++ = cast(ubyte) c;"

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 16 May 2022 at 18:17:03 UTC, Allen Garvey wrote: Thanks so much, that fixed the problem! You have no idea have long I have spent trying to debug this! Oh I should have checked my impl, where I did all this already!

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Tejas via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 09:38:31 UTC, Sergey wrote: On Monday, 16 May 2022 at 17:32:20 UTC, Allen Garvey wrote: I'm working on a comparison of WebAssembly performance for error propagation dithering using D, C++ and Zig. So far C++ and Zig work as expected, but for D, despite using the same

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Sergey via Digitalmars-d-learn
On Monday, 16 May 2022 at 17:32:20 UTC, Allen Garvey wrote: I'm working on a comparison of WebAssembly performance for error propagation dithering using D, C++ and Zig. So far C++ and Zig work as expected, but for D, despite using the same algorithm and similar code the output is different.

Re: D WebAssembly working differently than C++, Zig

2022-05-16 Thread Allen Garvey via Digitalmars-d-learn
On Monday, 16 May 2022 at 18:14:13 UTC, kinke wrote: The problem is the memset signature. You assume the length is the number of floats, while it's the number of *bytes* to be set to the specified value. https://en.cppreference.com/w/c/string/byte/memset Thanks so much, that fixed the

Re: D WebAssembly working differently than C++, Zig

2022-05-16 Thread Allen Garvey via Digitalmars-d-learn
On Monday, 16 May 2022 at 18:05:00 UTC, Adam D Ruppe wrote: I would suspect it is something to do with your memset... even if it needs to take the int (wtf but ldc is weird) you might want to reinterpret cast it to float to avoid any extra conversions. I was thinking memset might be the

Re: D WebAssembly working differently than C++, Zig

2022-05-16 Thread kinke via Digitalmars-d-learn
The problem is the memset signature. You assume the length is the number of floats, while it's the number of *bytes* to be set to the specified value. https://en.cppreference.com/w/c/string/byte/memset

Re: D WebAssembly working differently than C++, Zig

2022-05-16 Thread Adam D Ruppe via Digitalmars-d-learn
I would suspect it is something to do with your memset... even if it needs to take the int (wtf but ldc is weird) you might want to reinterpret cast it to float to avoid any extra conversions.

D WebAssembly working differently than C++, Zig

2022-05-16 Thread Allen Garvey via Digitalmars-d-learn
I'm working on a comparison of WebAssembly performance for error propagation dithering using D, C++ and Zig. So far C++ and Zig work as expected, but for D, despite using the same algorithm and similar code the output is different. You can see the differences here