Hybrid Detect demonstrates CPU topology detection using multiple intrinsic and OS level APIs.

Overview

Hybrid Detect

Hybrid Detect demonstrates CPU topology detection using multiple intrinsic and OS level APIs. First, we demonstrate usage of CPUID intrinsic to detect information leafs including the new Hybrid leaf offered for the latest Intel processors. Additionally, we use GetLogicalProcessorInformation() and GetLogicalProcessorInformationEX() to demonstrate full topology enumeration including Logical Core & Cache Relationships along with Affinity Masking. Finally we show how to use GetSystemCPUSetInformation() to get valid CPU Identifiers for use with SetThreadSelectedCPUSets() as well as how to read the Efficiency Class and other flags such as the Parked flag for each P-Core & E-Core.

In addition to topology detection several sample functions are demonstrated which control affinitization strategies for threads; these include weak affinity functions such as SetThreadIdealProcessor, SetThreadPriority, and SetThreadInformation, as well as strong affinity functions like SetThreadSelectedCPUSets and SetThreadAffinityMask.

HybridDetect.h is the primary source module for all Hybrid Detect functionality and requires no additional dependencies for integration into your project.

Projects in Solution

Hybrid Detect Console

Simple console based unit test for HybridDetect.h

HybridDetect.h Pre-Compiler Macros

// Enables/Disables Hybrid Detect
#define ENABLE_HYBRID_DETECT

// Tells the application to treat the target system as a heterogeneous software proxy.
//#define ENABLE_SOFTWARE_PROXY	

// Enables/Disables Run On API
#define ENABLE_RUNON

// Enables/Disables ThreadPriority Based on Core-Type
//#define ENABLE_RUNON_PRIORITY

// Enables/Disables SetThreadInformation Memory Priority Based on Core-Type
#define ENABLE_RUNON_MEMORY_PRIORITY

// Enables/Disables SetThreadInformation Execution Speed based on Core-Type
#define ENABLE_RUNON_EXECUTION_SPEED

// Enables CPU-Sets and Disables ThreadAffinityMasks
#define ENABLE_CPU_SETS

D3D12Multithreading

Demonstrates logical processor and cache topology enumeration using HybridDetect.h in a DirectX 12 rendering environment.

asteroids_d3d12

Demonstrates a variety of task scheduling scenarios with a simple task schedule using pre-compiler flags. Demonstrates split topology threadpools, as well as homogeneous/heterogeneous threadpool adaption. Rendering is done via the critical P-Cores and asteroid simulation is performed using E-Cores. Render/Update tasks can be composed into multiple task-dependency relationships, including SingleThreaded, NoDependency, OneToOne, Batched, and Asymmetric.

asteroids_d3d12 Command Line Arguments

'-scheduler [0-4]' controls how Render/Update task dependecies are composed

-scheduler 0 (Single Threaded)
-scheduler 1 (No Dependency)
-scheduler 2 (OneToOne)
-scheduler 3 (Batched)
-scheduler 4 (Asymetric)

asteroids_d3d12 Logical Threadpool Pre-Compiler

For Default Split-Topology threadpool, use the following pre-compiler flags:

#define RESERVE_ANY     0 // Hybrid Only, 1 reserves 2 'Any' threads affinitized to P-Cores & E-Cores
#define CORE_ONLY       0 // Hybrid Only, Run all Tasks in 'Core' threads.

For P-Core Only threadpool, use the following pre-compiler flags:

#define RESERVE_ANY     0 // Hybrid Only, 1 reserves 2 'Any' threads affinitized to P-Cores & E-Cores
#define CORE_ONLY       1 // Hybrid Only, Run all Tasks in 'Core' threads.

To demonstrate an alternative threadpool topology that reserves two threads that execute on P-Cores and E-Cores:

#define RESERVE_ANY     1 // Hybrid Only, 1 reserves 2 'Any' threads affinitized to P-Cores & E-Cores
#define CORE_ONLY       0 // Hybrid Only, Run all Tasks in 'Core' threads.
You might also like...
Security product hook detection

HookDump EDR function hook dumping Please refer to the Zeroperil blog post for more information https://zeroperil.co.uk/hookdump/ Building source In o

You Only Look Twice: Rapid Multi-Scale Object Detection In Satellite Imagery
You Only Look Twice: Rapid Multi-Scale Object Detection In Satellite Imagery

YOLT You Only Look Twice: Rapid Multi-Scale Object Detection In Satellite Imagery As of 24 October 2018 YOLT has been superceded by SIMRDWN YOLT is an

WhyNotWin11 - Detection Script to help identify why your PC isn't Windows 11 ready
WhyNotWin11 - Detection Script to help identify why your PC isn't Windows 11 ready

Detection Script to help identify why your PC isn't Windows 11 ready

Random stuff about lower level iOS

Lower Level iOS Random stuff about lower level iOS Topics Macho Parser - study note of Mach-O format Dynamic Linking Exported Symbol - details of how

A Header-Only Engine that tries to use SFML in a deeper level

βš™οΈ SFML-Low-Level-Engine βš™οΈ A header-only library that tries to use SFML at a deeper level πŸ’Ύ Instalation Download the source code and put the GLD fol

Writing our own printf function, this is a project done under ALX Low Level Programming.

0x11. C - printf Writing our own printf function, this is a project done under ALX Low Level Programming. Resource secrets of printf Implementing prin

Sqrt OS is a simulation of an OS scheduler and memory manager using different scheduling algorithms including Highest Priority First (non-preemptive), Shortest Remaining Time Next, and Round Robin.
Sqrt OS is a simulation of an OS scheduler and memory manager using different scheduling algorithms including Highest Priority First (non-preemptive), Shortest Remaining Time Next, and Round Robin.

A CPU scheduler determines an order for the execution of its scheduled processes; it decides which process will run according to a certain data structure that keeps track of the processes in the system and their status. A process, upon creation, has one of the three states: Running, Ready, Blocked (doing I/O, using other resources than CPU or waiting on unavailable resource).

The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.

libxo libxo - A Library for Generating Text, XML, JSON, and HTML Output The libxo library allows an application to generate text, XML, JSON, and HTML

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

Comments
  • GetLogicalProcessors misuses SYSTEM_CPU_SET_INFORMATION

    GetLogicalProcessors misuses SYSTEM_CPU_SET_INFORMATION

    In the docs for SYSTEM_CPU_SET_INFORMATION, MSDN expressly says:

    This is a variable-sized structure designed for future expansion. When iterating over this structure, use the size field to determine the offset to the next structure.

    However, the way GetLogicalProcessors iterates through the data returned from GetSystemCpuSetInformation completely disregards this note: https://github.com/GameTechDev/HybridDetect/blob/1a997834253d740492b1689ae365136c86c66686/HybridDetectConsole/HybridDetect.h#L389-L392

    While this code works now (although offset + sizeof(SYSTEM_CPU_SET_INFORMATION) <= size looks really weird to me and I don't understand the intentions behind it!), it will break if Microsoft ever decides to do as they say and expand this structure.

    For an example of proper usage of this data, see: https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/blob/5e42d181f2daf4a244450b1535223d4c71ea5e54/src/common/win32/Threads.cpp#L116-L127

    Strangely enough, the code snippet does adhere to the need of checking a Type field to ensure the data accessed is valid, so the only issue here is the misuse of size.

    bug 
    opened by CookiePLMonster 3
Owner
null
Anime browser built with AniList APIs, showcasing clean Flutter BLoC architecture

Anime browser built with AniList APIs. The purpose of this project is to showcase clean Flutter application architecture with BLoC design pattern.

Peter A. Bizjak 23 Nov 5, 2022
match(it): A lightweight header-only pattern-matching library for C++17 with macro-free APIs.

match(it): A lightweight header-only pattern-matching library for C++17 with macro-free APIs. Features Easy to get started. Single header library. Mac

Bowen Fu 434 Dec 27, 2022
A docker image where you can run a judge program and a converter for multiple sequence alignment

genocon2021-docker 本γƒͺγƒγ‚Έγƒˆγƒͺでは、ジャッジプログラム(eval.c)と Multiple Sequence Alignment (MSA) 倉換プログラム(decode_cigar.py)γ‚’εŒζ’±γ—γŸ Docker むパージを提供しています。 γΎγŸγ€γ‚΅γƒ³γƒ—γƒ«θ§£η­”γƒ—γƒ­γ‚°γƒ©γƒ (sam

Sakamoto, Kazunori 4 Sep 20, 2021
Run GTA:SA multiple times

Multi Process GTASA With this ASI mod you are able to run GTASA multiple times If you also wish to have windowed mode ability, you can use https://git

iAmir 13 Nov 8, 2021
A cross platform C99 library to get cpu features at runtime.

cpu_features A cross-platform C library to retrieve CPU features (such as available instructions) at runtime. Table of Contents Design Rationale Code

Google 2.2k Dec 22, 2022
Simple yet fancy CPU architecture fetching tool

Simple yet fancy CPU architecture fetching tool

null 1.6k Dec 28, 2022
GNU project's implementation of the standard C library(with Xuantie RISC-V CPU support).

GNU project's implementation of the standard C library(with Xuantie RISC-V CPU support).

T-Head Semiconductor Co., Ltd. 5 Mar 17, 2022
PoC memory injection detection agent based on ETW, for offensive and defensive research purposes

TiEtwAgent - ETW-based process injection detection This project was created to research, build and test different memory injection detection use cases

Filip Olszak 188 Dec 26, 2022
A 2D collision detection and physics library written in C.

A 2D collision detection and physics library written in C. WARNING: This library is in an early alpha stage, use it at your own risk. Documentation β€”

c-krit 85 Dec 24, 2022
Applications based on Wi-Fi CSI (Channel state information), such as indoor positioning, human detection

ESP-CSI The main purpose of this project is to show the use of ESP-WIFI-CSI. The human body detection algorithm is still being optimized. You can get

Espressif Systems 314 Jan 4, 2023