1st Interview from AMD Research
26 Jan 2018 Interview internship HW GPU Embedded MPIMainly about how CPU interacts with GPU.
Q1
Any GPU programming experience, for example using CUDA (Compute Unified Device Architecture)?
A1
No, I only heard about CUDA, but I do want to learn something about GPU.
Q2
Have you ever worked on a machine learning project?
A2
No…
Q3-1
In embedded system project you participated in, how does the CPU communicate with peripherals?
A3-1
For each peripheral, it has control register and data registers. And the core reads/writes those registers. For example set a bit in the control register to start the peripheral. When the data is ready in data register, generate an interrupt or the core just read the control register to know whether the data is ready or not.
Q3-2
So it is memory mapping. Do you know any other ways to exchange data?
A3-2
AXI (Advanced eXtensible Interface) bus? Is it another way?
Interviewer: Yes. Bus protocol is an old way.
Q4-1
How to use MPI (Message Passing Interface)?
A4-1
Send package when updating data, also define handler functions to process received message.
Q4-2
In MPI, there are two kinds of send functions, send and isend. Former is blocking and latter is non-blocking, what’s the diffence between those two and why we need to do non-blocking?
A4-2
Blocking means the process or thread needs to wait there until receive message from others, while non-blocking can move forward to do other things first.
We using non-blocking to save time.
Q4-3
In non-blocking mode, how to make sure it is the original thread that handles the message, rather than a random but incorrect thread handles the data?
A4-3
Set a callback function, so when the message comes, the callback function is invoked to handle the data.
Interviewer: Callback is one way. Another way is loop on a function to check whether there is a message arrived, if so, execute handler function, otherwise keep polling.
Q5-1
What kind of data structure is used to pass message between CPU and GPU?
A5-1
???
Q5-2
CPU send message to GPU, then GPU buffers them, but how to avoid buffer overfolow?
A5-2
Use FIFO. There are two pointers. If those two pointers point to the same location, the buffer is full.
Interviewer: FIFO or circular buffer? According to your description on the two pointers, I guess you are talking about circular buffer?
Yes, circular buffer. I think usually FIFO are implemented as a circular buffer.
Q5-3
OK, so implement a FIFO as a circular buffer. And let’s say there is a CPU producer, and a GPU consumer, what do they do to use the buffer?
A5-3
When CPU produces a data, it puts the data to the buffer, the slot pointed by a pointer, then move the pointer to the next available slot. When GPU takes a data, it take the data pointed by another pointer then move pointer to the next available data.
Interviewer: What operations to do before CPU touch the buffer?
Oh, it should compare the value of the two pointers first to determine whether the buffer is full or not. And also the GPU should compare the value of the two pointers to see if the buffer is empty.
Q5-4
When the two pointers are pointing to the same place, is the buffer full or empty? How do you know?
A5-4
It depends on how to define the meaning of those two pointers.