Skip to content

Conversation

bratpiorka
Copy link
Contributor

@bratpiorka bratpiorka commented Sep 18, 2024

This PR enables GPU IPC (Inter-Process Communication) tests on Windows by implementing Windows-specific socket functionality and memory exchange mechanisms. The changes introduce a new memory exchange policy for Level Zero providers to work around IPC limitations on Windows.

Key changes:

  • Implements Windows socket support in IPC test infrastructure using Winsock2
  • Adds new memory exchange policy (import/export) for Level Zero providers on Windows
  • Creates Windows batch scripts for running GPU IPC tests

@bratpiorka bratpiorka force-pushed the rrudnick_ipc_win branch 5 times, most recently from 6da36e1 to da553d7 Compare September 19, 2024 08:08
@bratpiorka bratpiorka force-pushed the rrudnick_ipc_win branch 3 times, most recently from a77f891 to 78361c2 Compare September 16, 2025 14:49
@bratpiorka bratpiorka changed the title enable IPC tests and examples on Windows enable GPU IPC tests and examples on Windows Sep 16, 2025
@bratpiorka bratpiorka force-pushed the rrudnick_ipc_win branch 6 times, most recently from 976028a to cfc6f31 Compare September 17, 2025 08:27
@bratpiorka bratpiorka changed the title enable GPU IPC tests and examples on Windows enable GPU IPC tests on Windows Sep 17, 2025
@bratpiorka bratpiorka marked this pull request as ready for review September 17, 2025 12:03
@bratpiorka bratpiorka requested a review from a team as a code owner September 17, 2025 12:03
Copy link
Contributor

@lukaszstolarczuk lukaszstolarczuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job in general, a few minor issues

@bratpiorka bratpiorka force-pushed the rrudnick_ipc_win branch 7 times, most recently from d0aca41 to becaa7d Compare September 17, 2025 18:36
@bratpiorka bratpiorka force-pushed the rrudnick_ipc_win branch 9 times, most recently from 1d41c75 to 152c072 Compare September 18, 2025 08:15
@bratpiorka bratpiorka marked this pull request as draft September 19, 2025 09:40
memcpy(&ze_ipc_handle, &fd_local, sizeof(fd_local));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove tab

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

CloseHandle(source_process_handle);

return result ? UMF_RESULT_SUCCESS : UMF_RESULT_ERROR_UNKNOWN;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will always return UMF_RESULT_SUCCESS since you check error at 79.
Otherwise:

Suggested change
}
release_current:
CloseHandle(current_process_handle);
release_source:
CloseHandle(source_process_handle);
return result;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 79 to 83
if (!result) {
LOG_ERR("DuplicateHandle() failed for pid=%d fd_in=%d.", pid, fd_in);
CloseHandle(current_process_handle);
CloseHandle(source_process_handle);
return UMF_RESULT_ERROR_UNKNOWN;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!result) {
LOG_ERR("DuplicateHandle() failed for pid=%d fd_in=%d.", pid, fd_in);
CloseHandle(current_process_handle);
CloseHandle(source_process_handle);
return UMF_RESULT_ERROR_UNKNOWN;
}
if (!result) {
LOG_ERR("DuplicateHandle() failed for pid=%d fd_in=%d.", pid, fd_in);
result = UMF_RESULT_ERROR_UNKNOWN;
goto release_current;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 70 to 71
if (!source_process_handle) {
LOG_ERR("OpenProcess() failed for pid=%d.", pid);
CloseHandle(current_process_handle);
return UMF_RESULT_ERROR_UNKNOWN;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!source_process_handle) {
LOG_ERR("OpenProcess() failed for pid=%d.", pid);
CloseHandle(current_process_handle);
return UMF_RESULT_ERROR_UNKNOWN;
}
BOOL result;
if (!source_process_handle) {
LOG_ERR("OpenProcess() failed for pid=%d.", pid);
result = UMF_RESULT_ERROR_UNKNOWN;
goto release_source;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


int producer_connect(int port) {
struct sockaddr_in consumer_addr;
int ret = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used only at the end of the function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@bratpiorka bratpiorka force-pushed the rrudnick_ipc_win branch 6 times, most recently from 89ec750 to c423e04 Compare October 2, 2025 07:42
@bratpiorka bratpiorka requested a review from Copilot October 2, 2025 07:50
@bratpiorka bratpiorka marked this pull request as ready for review October 2, 2025 07:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables GPU IPC (Inter-Process Communication) tests on Windows by implementing Windows-specific socket functionality and memory exchange mechanisms. The changes introduce a new memory exchange policy for Level Zero providers to work around IPC limitations on Windows.

Key changes:

  • Implements Windows socket support in IPC test infrastructure using Winsock2
  • Adds new memory exchange policy (import/export) for Level Zero providers on Windows
  • Creates Windows batch scripts for running GPU IPC tests

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/common/ipc_common.c Adds Windows socket implementation with Winsock2 support for IPC communication
test/providers/ipc_level_zero_prov_producer.c Sets import/export memory exchange policy on Windows instead of IPC
test/providers/ipc_level_zero_prov_consumer.c Sets import/export memory exchange policy on Windows instead of IPC
test/providers/ipc_level_zero_prov.bat Windows batch script for Level Zero IPC tests
test/providers/ipc_cuda_prov.bat Windows batch script for CUDA IPC tests
test/CMakeLists.txt Moves GPU IPC test configuration to support Windows and adds Winsock2 library
src/provider/provider_level_zero.c Implements new memory exchange policy with import/export APIs
src/utils/utils_windows_common.c Implements Windows handle duplication functionality
test/providers/provider_level_zero_not_impl.cpp Adds test for new memory exchange policy API
include/umf/providers/provider_level_zero.h Defines new memory exchange policy enum and API
src/libumf.def Exports new memory exchange policy function

Comment on lines +461 to +462
*(uintptr_t *)lastNext =
(uintptr_t)&relaxed_device_allocation_desc_copy;
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using uintptr_t casting to manipulate pNext pointers is unclear and potentially unsafe. Consider using proper pointer casting like *(void **)lastNext = &relaxed_device_allocation_desc_copy; for better type safety and readability.

Copilot uses AI. Check for mistakes.

if (ze_provider->exchangePolicy ==
UMF_LEVEL_ZERO_MEMORY_PROVIDER_MEMORY_EXCHANGE_POLICY_IMPORT_EXPORT) {
// add external memory export desc to the pNext chain
*(uintptr_t *)lastNext = (uintptr_t)&memory_export_desc_copy;
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above - using uintptr_t casting to manipulate pNext pointers is unclear and potentially unsafe. Consider using proper pointer casting like *(void **)lastNext = &memory_export_desc_copy; for better type safety and readability.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@lukaszstolarczuk lukaszstolarczuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

4 participants