Gusty flow over rough terrain is likely to be a significant source of fast gravity waves and acoustic waves in the atmosphere of Mars, as it is in Earth's atmosphere. Accordingly, we have used a numerical model to study the dissipation in the thermosphere and exosphere of Mars of upward-propagating fast gravity waves and acoustic waves. Model simulations are performed for a range of wave periods and horizontal wavelengths. Wave amplitudes are constrained by the Mars Global Surveyor and Mars Odyssey aerobraking data, and gravity wave phase velocities are limited by occultation data. Dissipating gravity waves heat some regions of the thermosphere and cool others through the effects of sensible heat flux divergence, while acoustic waves mainly heat the Mars thermosphere. Heating rates can be on the order of several hundred Kelvin per day. The cycle-integrated effects on the Jeans escape flux are also investigated and found to be on the order of background values and even greater and might be a significant source of loss of the Martian atmosphere to space.