Skip to content

fix(ventus): add missing reinit function to ensure proper device cleanup#101

Open
menxb wants to merge 2 commits intomainfrom
fix/ventus-uninit-for-main
Open

fix(ventus): add missing reinit function to ensure proper device cleanup#101
menxb wants to merge 2 commits intomainfrom
fix/ventus-uninit-for-main

Conversation

@menxb
Copy link
Copy Markdown
Collaborator

@menxb menxb commented Aug 27, 2025

Problem

Currently, the Ventus device in POCL has ops->reinit set to NULL, which causes pocl_uninit_devices() to skip the cleanup process for Ventus devices. This results in a resource leak where vt_dev_close() is never called, preventing proper device cleanup.

Solution

This PR adds the missing pocl_ventus_reinit() function to ensure proper device lifecycle management:

  • Add pocl_ventus_reinit function to fix uninit not being called issue
  • Implement proper device re-initialization with hardware connectivity reset
  • Reset command queue state and device connection
  • Ensure ventus device follows pocl device management lifecycle
  • Fix resource leak where vt_dev_close was not called due to missing reinit

Key Changes

  • Added pocl_ventus_reinit() function in pocl_ventus.cc
  • Added function declaration in pocl_ventus.h
  • Set ops->reinit = pocl_ventus_reinit instead of NULL

Technical Details

The reinit function:

  1. Safely closes existing device connection (vt_dev_close)
  2. Re-opens the device connection (vt_dev_open)
  3. Resets command queue state (ready_list, command_list, current_kernel)
  4. Handles proper error checking and logging

Testing

  • Verified that device cleanup now works properly
  • Confirmed vt_dev_close() is called during uninit process

Fixes issue where pocl_uninit_devices skips ventus device cleanup because ops->reinit was NULL, preventing proper resource cleanup.

- Add pocl_ventus_reinit function to fix uninit not being called issue
- Implement proper device re-initialization with hardware connectivity reset
- Reset command queue state and device connection
- Ensure ventus device follows pocl device management lifecycle
- Fix resource leak where vt_dev_close was not called due to missing reinit

Fixes issue where pocl_uninit_devices skips ventus device cleanup
because ops->reinit was NULL, preventing proper resource cleanup.
- Add proper reinit function for Ventus device following POCL framework patterns
- Reuses hardware connection setup consistent with init function
- Properly handles memory allocation, error cases, and device state reset
- Follows same error handling and resource management as pocl_ventus_init
- Only reinitializes runtime state, skips static device properties

This resolves device reinitialization issues for Ventus GPU devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant