Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8037

Teaching and learning resources • Re: Advent of Code 2024

$
0
0
The kittens are difficult to motivate so this may not work out, but I'm hoping.
It looks like there has been some progress with the super cheap cluster. In order to keep the MPI parallel programming examples together, the program for solving the day 24 puzzle will be described at

viewtopic.php?p=2315193#p2315193
The finished MPI code is at

viewtopic.php?p=2316257#p2316257

Since it's also possible to run MPI code on a multi-core SMP machine, I installed MPICH on the Pi 4.

The result

Code:

$ mpirun -n 4 ./mpi24 # Pi 4B 1500 MHzAdvent of Code 2024 Day 24 Crossed Wires (mpi_size=4)Part 1 The z wires output 61495910098126Part 2 Swap wires css,cwt,gdd,jmv,pqt,z05,z09,z37Total execution time 1.23296 seconds.
indicates a factor

4.69 / 1.23 = 3.81

fold increase in performance over the parallel Go code and even more compared to Chapel.

The algorithm is basically the same. I was a little more careful allocating memory on the stack in C and represented the leaf list used for the topological sort as a n x 3 array rather than an array of slices. Maybe this last change accounts for most of the improvement. It's difficult to tell without testing.

Statistics: Posted by ejolson — Sun May 25, 2025 6:13 am



Viewing all articles
Browse latest Browse all 8037

Trending Articles