esp32s3 QR Register State Saving

esp_programmer
Posts: 16
Joined: Wed Jul 12, 2023 4:26 am

esp32s3 QR Register State Saving

Postby esp_programmer » Wed Jul 19, 2023 4:40 am

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

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: esp32s3 QR Register State Saving

Postby ESP_igrr » Wed Jul 19, 2023 6:09 am

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.

esp_programmer
Posts: 16
Joined: Wed Jul 12, 2023 4:26 am

Re: esp32s3 QR Register State Saving

Postby esp_programmer » Wed Jul 19, 2023 9:40 pm

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

Who is online

Users browsing this forum: No registered users and 29 guests