Whether or not spell damage is magical or not is entirely irrelevant to resistances and immunity. Heavy Armour Master and every creature I have seen with resistance or immunity to bludgeoning, piercing, and slashing damage are safe from "bludgeoning, piercing, and slashing damage from nonmagical weapons." Whether or not spell damage counts as magical doesn't matter because it is not damage from a weapon.
Edit: I'm assuming that your question is relating to how it interacts with resistance and immunity, and not how it would interact with other spells (such as Detect Magic or Antimagic Field).
Edit 2: To answer your examples, Ice Knife is not a weapon, and therefore bypasses all resistance to nonmagical weapons such as HAM and most piercing resistant monsters (though not raging barbarians). Fiendish Resilience would resist magical damage so long as that damage is not coming from a magical weapon. For instance, it could resist the fire damage from Fireball, the piercing from a peasant's dagger, or the lightning from a blue dragon's breath, but not slashing damage from a +1 longsword or bludgeoning from a flesh golem.
Edit 3: Hopefully my last edit. As far as I can tell, there is no difference between magical and nonmagical for any damage types except bludgeoning, piercing, and slashing, and even those only care if it is a weapon dealing damage. Burning Hands and a flaming building both deal fire damage, and there is no mechanical effect of one being magical and the other not (correction: it matters for some creatures' Magic Resistance trait). Poison damage from an assassin's blade, a green dragon's breath, and the Poison Spray cantrip are also all the same.