a. He gave a thought to this matter.
b. He gave thought to this matter.
Do they mean the same thing?
"A thought" is brief. "Thought" is more involved.
Another issue here, which is very interesting, is the cases when nouns in English require an article compared to those times that an article is optional or forbidden. The noun, "thought(itself a past participle that has changed its job)" is one of those nouns that sometimes does not need an article.
Almost all concrete common nouns require an article in almost all cases in English. Most common abstract nouns, on the other hand, do not need an article, and in many cases, using such a noun with an article is a mistake.
"Thought" can either be concrete or abstract. It is concrete when it refers to a person's thinking: "I had a thought," or "the thought that I just had is a little scary." It is abstract when it refers to the human capacity to think, or to all of the thinking on a subject or in general.
The sentence, "Give thought to this matter" means to use the ability to think about something to figure something out. It means to think about it more generally and more deeply.
The sentence, "Give a thought to this matter" means that the person given the command ought to consider something at least enough to think about it specifically, to have at least a single concrete idea about it.
Interestingly enough, both of these imperative sentences can sound like a warning or a caution. The one suggests that maybe a lot of complexity is present. The second suggests that one should watch out for obvious traps or problems that even one second of thinking might discover.