'Whole' has the sense of 'complete' and 'all' indicates every part of something. For example if we mean from the beginning of the day until the end of the day, we would say: the whole day. We can also say: all (the) afternoon, which suggests every part of the afternoon. Briefly the difference is that 'whole' refers to the entirety of something whereas 'all' refers in particular to all the parts/bits that make up the afternoon. In this sentence: Charlie ate the whole cake, there is simply an indication that the complete cake was eaten. Charlie ate all the cake (all of the cake) suggests that possibly it was surprising that he did that because it was a big cake and he managed to consume every single bit of the cake.