Ultraviolet structure of half-maximal supergravity with matter multiplets at two and three loops