pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
962 stars 306 forks source link

Free resources in cpuinfo_deinitialize #208

Open prashanthswami opened 7 months ago

prashanthswami commented 7 months ago

Users of the library can choose to release all resources the library may have allocated as part of a previous cpuinfo_initialize call. If no resources were previously allocated, this function does nothing.

Callers cannot re-initialize after the cpuinfo_deintialize call, as the library assumes initialization is a one-time operation per-process. Further, de-initializing can invalidate pointers previously acquired from cpuinfo (e.g. structures returned from cpuinfo_get_current_processor).

As such, callers should only call cpuinfo_deinitialize when:

  1. There are no further uses of references returned from cpuinfo.
  2. There are no further calls to cpuinfo_* functions.

Fixes #150

prashanthswami commented 7 months ago

Review: @malfet