Page 1 of 1

esp32s3 QR Register State Saving

Posted: Wed Jul 19, 2023 4:40 am
by esp_programmer
Hi,

Not sure if this is a silly question, but what happens to the PIE QR registers on a context switch or interrupt? I am assuming that nothing happens unless a user specifically saves/restores them. Is this correct?

Thanks
esp_programmer

Re: esp32s3 QR Register State Saving

Posted: Wed Jul 19, 2023 6:09 am
by ESP_igrr
We perform lazy context switching, same as for the FPU:

1. When switching the tasks, the coprocessors (FPU and PIE) are disabled
2. If the new task never used FPU or PIE, there's nothing to do
3. If the new task does try to use FPU or PIE, this triggers a "coprocessor disabled" exception. The exception handler will check which task's registers are in the coprocessor right now. If the last task that used he coprocessor is the same task, then we can simply re-enable the coprocessor. If it was a different task, then we save its registers to the save are of that last task, and then load the registers from the save are of the new task, then re-enable the coprocessor.

This solution avoids the penalty of saving/restoring registers if coprocessors are never used.

From the application perspective, all these manipulations are invisible. You can assume that each task has its own set of PIE registers. Of course, the highest performance will be achieved when only one task on each CPU uses the coprocessor.

Re: esp32s3 QR Register State Saving

Posted: Wed Jul 19, 2023 9:40 pm
by esp_programmer
Thanks ESP_igrr for that very informative response.

Just another question, can you confirm that each core has its own PIE co-processor? That is, there are two independent PIE co-processors on the ESP32S3?

Thanks