What is the difference between grammatical functions and semantic roles? Are they the same?
Traditionally, a grammatical function is "how it works in a grammar", so ability to triggering agreement, be nominative, bind a reflexive and so on are grammatical functions. Grammatical relations are concepts like "Subject", "Object", "Indirect Object" etc, which are related, in that being a subject implies having certain functions. But subjects can have very many different semantic roles, for example "agent" (Bob hit me), "patient" (Bob underwent surgery), "involuntary causer" (Water rotted the deck), "instrument" (the rock broke the glass), "experiencer" (Bob heard me) all of which have one grammatical relation, subject (and subjects have various grammatical functions).
The two word string 'grammatical function' is sometimes used in ad hoc ways by different scholars, where grammatical is an adjective and function is a broad descriptive word, and the two-word string does not refer to any type of formal category. However, the fact that the Original Poster is asking this question—and that they frame it in the way they do—strongly suggests that they've encountered this term in a context where it refers to a formal category, as used in modern reference grammars such as Oxford Modern English Grammar (Aarts, 2011). Here 'grammatical function' means 'grammatical relation' in the traditional sense, also commonly referred to as 'syntactic function', for example in The Cambridge Grammar of the English Language (Huddleston & Pullum, 2002).
Within grammars such as Oxford Modern English Grammar (OMEG), the term grammatical function refers to the job that a phrase or word does in terms of the architecture of a larger phrase or clause. The most basic architecture of a clause in English can be broken down into two structural units, two chunks of words. The first is the Subject, the second, the Predicate. In the following example, the Subject is The baboon and the Predicate is the verb phrase bit the biologist:
(1) The baboon bit the biologist.
In terms of meaning, we can say that the baboon was the thing doing the biting action. We can describe this as The baboon representing the ᴀɢᴇɴᴛ of the action. And in terms of meaning, we can say that the biologist represents the thing/person that the action was performed on, the ᴘᴀᴛɪᴇɴᴛ.
We can compare sentence (1) with (2) below:
(2) The biologist was bitten by the baboon.
This sentence has the same meaning as (1). The ᴀɢᴇɴᴛ is still represented by the baboon, the entity doing the biting action. The ᴘᴀᴛɪᴇɴᴛ is still the biologist. However, here the Subject is The biologist, not and the baboon appears inside the Predicate, was bitten by the baboon.
So, in short, 'grammatical functions' refer to the job that a word or phrase is doing in the architecture of a sentence. The term semantic role refers to which part a chunk of words plays in the story told by the verb.