When we prohibit "discrimination" what do we normally mean? It is that the prohibited criteria (race, sex, religion, age) should not be considered. Two people applying for a job, one male and one female; the decision should be made without consideration of either person's sex (assuming that sex is not a bona fide occupational qualification or BFOQ).
The BFOQ is an example of when we make a specific exception to the general rule that a prohibited criteria should not be considered. Another (unwritten) exception would be the "heightened scrutiny" applicable to certain kinds of presumptively unconstitutional discrimination by state actors under the Equal Protection Clause of the Fourteenth Amendment. So states can provide contracting preferences for certain racial groups if the preferences meet the requirements of "strict scrutiny." These exceptions are permissive, not mandatory. A state agency can provide contracting preferences, but generally speaking, it is not required to do so.
As I pointed out yesterday, Title IX has some explicit exceptions (e.g., for father-son and mother-daughter events). These exceptions are permissive. The statute permits sex-segregated housing, but it does not require it.