Not sure where to point you for it, so here's some info. Formatting is going to be awful here, but bear with me. To calculate necessary gain, you can use this equation:
Gain = Output (Vrms) / Input Sensitivity (Vrms)
Assume input sensitivity is equal to your source device's rated output voltage. Let's say 2V for simplicity's sake here, but it can be all over the place depending on what you're using.
Now most things don't give you output voltage, so use this to find that for your amp.
E = sqrt( P * R ) [Voltage = sqrt( Power in Watts * Resistance in Ohms)]
^ This is just Ohm's Law if anyone doesn't know where this comes from.
Magni 3 for example, because it's easy to find these numbers for it:
E = sqrt(2 Wrms * 32 ohms)
E = 8 V
You get 8 Vrms out of a Magni 3.
Gain = 8 V / 2 V
Gain = 4
You need a gain of 4 to get full output from a Magni 3 with a 2 Vrms source.
Now, you can skip over all of this if you have a rated input sensitivity. Just compare your output to the required input. Realistically, you want more source voltage available than the minimum required by the input sensitivity if you're aiming for that full output. This is because you probably don't listen to nothing but full scale sine waves. Real music sits below that full output, some significantly more than others.
Obviously, you can swap different known elements in to figure out different things. If you have a known gain, you can find input sensitivity, for example.
We know the Magni 3 has a gain option of 2 or 7. 2 is going to net us 4V of the 8V available at full output. That's fine... but you're not going to make use of the full 2W output. At 7, you'd swing 14V if it was capable of it. Instead, you're chopping off 6V (sort of... all of these numbers are RMS, and it'll swing more to the peaks, but ignore that and just assume you're clipping signals here anyway) if you run full 2V into it with no attenuation. But like I said, music isn't full scale all the time, and you're probably using that volume knob.
Of course, my original comment on full output and gain not being load dependent doesn't mean everything else isn't. Do you actually need full output is the next question. You have a super sensitive Grado or just about any in ear, and an amp that will dump 2W into that impedance. 2W is well in excess of SPLs capable of deafening you for both options. I mean, it's probably going to kill those drivers too, but whether you actually need full output is important too, and a lot of things are getting so powerful that you probably don't a lot of times. If you don't need 2W, that low gain of 2 and the 4V swing is potentially very useful now. If you actually needed more than 2W, then you want a bigger amp, not more gain. That's just distortion and compression, not real power.
So it all depends... Sometimes less than full is great, others you're great at that ideal number, and sometimes you still need just a little more. But let's say the Magni had 3 gain settings, 2, 6, and 12. You have no need for that 12 in any scenario with that 2 V source. The 6 already does more than it's capable of. 12 is just additional distortion over the 6. All I'm really saying in all of this is if you have enough to hit your max at a lower setting, that higher one is only going to do negative things.
You really need to know how much power you actually need if you want to calculate every little detail about what is enough for you, but don't worry about it too much. It's only really worth thinking about if you're curious which gain setting to use on something with options, or you're trying to minimize any excess gain in a chain or something.