Precision bounds for gradient magnetometry with atomic ensembles