Timeline for Optimisation: Fastest way to multiply every number in an array by 2
Current License: CC BY-SA 4.0
33 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 7, 2023 at 19:42 | history | edited | Henners2002 | CC BY-SA 4.0 |
edited title
|
Nov 7, 2023 at 19:36 | history | edited | Henners2002 | CC BY-SA 4.0 |
added 54 characters in body
|
Nov 7, 2023 at 19:30 | answer | added | Henners2002 | timeline score: 1 | |
Nov 7, 2023 at 19:22 | history | edited | Henners2002 | CC BY-SA 4.0 |
added 1125 characters in body
|
Nov 7, 2023 at 1:45 | answer | added | user555045 | timeline score: 1 | |
Nov 6, 2023 at 22:18 | history | edited | Sᴀᴍ Onᴇᴌᴀ♦ | CC BY-SA 4.0 |
update image description
|
Nov 6, 2023 at 21:54 | history | edited | greybeard | CC BY-SA 4.0 |
replace rendered markup with the real thing - as a preformatted block. Interpreted, it looks - spaceous
|
Nov 6, 2023 at 20:11 | comment | added | iSR5 | @Henners2002 I just saw the results, I'm glad that helped through your journey. | |
Nov 6, 2023 at 20:03 | history | edited | Henners2002 |
edited tags
|
|
Nov 6, 2023 at 19:53 | comment | added | Henners2002 | @iSR5 I have tested it it was 100% worth it you can check the thread for the results. | |
Nov 6, 2023 at 19:51 | comment | added | iSR5 | @Henners2002 honestly, I haven't used it with vectorized calculations, but you can test it out, and see if it's going to be worth it. | |
Nov 6, 2023 at 17:39 | history | edited | Henners2002 | CC BY-SA 4.0 |
edited title
|
Nov 6, 2023 at 14:58 | history | edited | Henners2002 | CC BY-SA 4.0 |
added 127 characters in body
|
Nov 6, 2023 at 12:58 | answer | added | Henners2002 | timeline score: 1 | |
Nov 6, 2023 at 12:14 | answer | added | Henners2002 | timeline score: 1 | |
Nov 6, 2023 at 10:58 | comment | added | Henners2002 | @iSR5 Is it possible to use the MemoryMarshall approach on vectorised calculations? | |
Nov 6, 2023 at 10:54 | answer | added | Henners2002 | timeline score: 3 | |
Nov 4, 2023 at 14:12 | comment | added | iSR5 |
using Span<T> would be a better approach, but you need to keep thread-safety in mind. There is also MemoryMarshal approach, but I don't think it would be worth as you might gain a very tiny speed over Span , unless you have a huge arrays, then it might worth a tray.
|
|
Nov 3, 2023 at 13:52 | comment | added | Henners2002 | @AlexanderPetrov Code has been corrected and Benchmarks updated. Do you have any performance enhancements I could try? | |
Nov 3, 2023 at 13:51 | history | edited | Henners2002 | CC BY-SA 4.0 |
added 380 characters in body
|
Nov 3, 2023 at 12:44 | comment | added | Alexander Petrov |
Show a fully working example. Now your code does not copy values from testSpace to result at all, multiplying zeros in this way.
|
|
Nov 3, 2023 at 12:41 | comment | added | Alexander Petrov | Do size 999 or 1001 and see yourself. | |
Nov 3, 2023 at 12:38 | comment | added | Henners2002 |
@AlexanderPetrov Yes it does. In the loop condition there is testSpace.Length - testSpace.Length % batchSize This ensures the the upper limit of the loop is always a multiple of batchSize
|
|
Nov 3, 2023 at 12:36 | comment | added | Alexander Petrov |
Your code has a bug. It does not handle the tail remaining in the case when the array size is not a multiple of batchSize .
|
|
Nov 3, 2023 at 12:35 | comment | added | Henners2002 | @OlivierJacot-Descombes Yeah I think the TPL would be a good option of the test space was larger. Maybe If I played around with this and the degree of parallelism I could get better results. | |
Nov 3, 2023 at 12:31 | comment | added | Henners2002 | @PeterCsala I have included Benchmarks of five relevant methods | |
Nov 3, 2023 at 12:31 | comment | added | Olivier Jacot-Descombes | Note that tasks must have chunks to process that are big enough in order to compensate for the overhead involved in task management. Did you have a loop into Task Parallel Library (TPL)? | |
Nov 3, 2023 at 12:30 | history | edited | Henners2002 | CC BY-SA 4.0 |
added 171 characters in body
|
Nov 3, 2023 at 12:24 | comment | added | Peter Csala | Anything that extends the review context is more than welcome. | |
Nov 3, 2023 at 12:23 | comment | added | Henners2002 | @PeterCsala I ran a benchmark. I can post the results of that if you would like. I've compared it against LINQ, a regular for loop and a SIMD instruction with heap allocation | |
Nov 3, 2023 at 12:21 | comment | added | Peter Csala | How did you measure the performance of your code? | |
Nov 3, 2023 at 12:20 | history | edited | Peter Csala | CC BY-SA 4.0 |
deleted 37 characters in body
|
Nov 3, 2023 at 12:00 | history | asked | Henners2002 | CC BY-SA 4.0 |