Inclusive and semi-inclusive pion production in pp collisions at 102 and 400 GeV/c