Guppies spend a decent amount of time at the top, but not exclusively so and will swim in all areas of the tank. It would definitely be a good idea to test for ammonia and nitrite. Spending a lot of time at the top and 'gasping' is a sign that they are struggling to get oxygen, and ammonia/nitrite poisoning is a common cause.
How old is the tank? If its a new set-up it definitely is a issue with ammonia/nitrite.