Nvidia Interview Experience for Compiler Engineer
My Background: I worked in the compiler frontend (Clang) during my thesis developing a compiler-like tool for static analysis of C language. Basically a linter for C programming language. I am from Tier 1 college (IIT). I am 1+ years experienced.
Hiring Manager Round: He worked in the GPU compiler optimization team at NVIDIA. Talked about stuff he does related to compiler optimizations. Asked questions about compiler optimizations like loop optimizations and peephole optimizations since I knew he is from the optimization team I prepared this stuff in advance. But I clearly told him that I have never worked in the optimizations field. Note: Compiler optimization is a compiler backend where you also need architecture-related knowledge.
Round 1: Coding
- Print all the permutations of string? I told him to change the question since I didn’t revise backtracking for this interview.
- He was humble enough to change the question.
- Merge sort on the linked list with detailed runtime analysis?
- I answered the question successfully but made mistake in analyzing the runtime. I implemented the approach of dividing the linked list into two halves and merging the two halves and recursively applying quicksort I told him it is O(n^2) which was wrong. But even he didn’t know that I made a mistake in analysis and he kept on suggesting a method to reduce it to O(N log N) which was wrong.
- How to implement hashmap? Possible approaches in defining the hash function for mapping keys?
Round 2: Coding
- Find min element in a binary tree?
- C code to extract words from a sentence and copying it to 2d array where each row contains a word. The code was a little complex. There he was copying the strings by breaking the whole sentence and also memory manipulation with really was done to handle the case of insufficient memory if the allocated memory is less than allocated earlier.
E.g: I/p: Nvidia is a cool organization. O/p: Nvidia is a cool organization
- There is a 3×3 matrix of storing apps like
A1 A2 A3 A4 A5 A6 A7 A8 A9
- You need to maintain the top 9 apps in this matrix. How will you do it?
- Now he didn’t mention anything apart from this. I didn’t ask him any questions and moved forward with the solution which was a mistake. I said I will do it using the priority queue. Then he said how the priority queue will work so I explained to him the insertion and deletion of a node in heap for 20 mins then he said “ohh” but it will not be maintaining the order right? I was like what. He said can you think of other data structures for this?
- Then again after thinking for 10 mins I said I will store it using a linked list and map. Basically, it is Implement LRU cache standard problem. Which I saw a day back but couldn’t think about it at the actual moment. I told him how I will implement it and he didn’t ask me to code it and this interview was done.
Round 3: Design Skills
- How do you reduce the cache misses in the case of multiplying 2 very large matrices? I couldn’t answer it since I had no idea how cache will work in this case.
- Then he asked a long cryptic compiler-related problem. It goes like this….
- Let’s say compiler A calls compiler B’s “invoke” module 15 times and during that it performs some steps where the percentage of time consumed is written alongside
Initializing a compiler instance 15% Preprocessing 25% Syntax analysis 25% Optimizations 35%
- How will you minimize the time consumed? Now, what do you get by this problem?
- Do I need to make 15% to 10%? What is the meaning of reducing the time? It took me 25 mins to clarify the problem from the interviewer. Basically, he wanted to know like do we need to initialize the compiler instance for all 15 calls or do we need to perform preprocessing again and again or not?
- So after I finally understood the problem I answered all his questions successfully. I told him we can have an if check if the compiler is already initialized. We can pass the argument to the invoke function to take the compiler instance. We can store a map to store the preprocessor-related data and can use flags to know if syntax analysis was done already or not then he asked followup like can we remove if conditions then I said like checking the map size and stuff. So basically I handled his questions well.
Round 4: Clang knowledge
- This was the most sensible interview. She asked me all the details about my project and how I approached the problem and what data structures and design patterns I used for it.
- So basically she was interested in the work and since I did my project really well I knew each and every stuff she asked me regarding it.
Round 6: Compiler Director Round (Cultural Fit)
- He asked questions about my project and some things like why do you want to join this difficult and boring field. Basically, after his demotivation, I decided I don’t want to join this field.
- After a week they said they were not satisfied with coding rounds so they want one more coding round.
Round 7: Coding
Given a tree convert it to a sum tree?
E.g: 2 19
/ \ / \
3 4 ———-> 15 4
/ \ / \
5 7 5 7
- I gave him O(n^2) approach. He wanted to reduce it to O(n) which I was not able to do.
I felt relaxed. Because they contacted me in May 2021 and scheduled the first round in 17th Sept 2021 which they rescheduled at the end moment to next week since they were not available. Thank god I didn’t take leave early from my current organization. Then on the interview day, the first round didn’t happen because the guy was not available. The coding people didn’t give any hints. The last interviewer was horrific. He became dead silent after asking the question. When he spoke he had too much arrogance in his voice. Please dont keep such people who are there to satisfy their ego. Thank god I didn’t answer properly.