xref: /aosp_15_r20/external/gmmlib/Source/GmmLib/ULT/GmmMultiAdapterULT.h (revision 35ffd701415c9e32e53136d61a677a8d0a8fc4a5)
1*35ffd701SAndroid Build Coastguard Worker /*========================== begin_copyright_notice ============================
2*35ffd701SAndroid Build Coastguard Worker 
3*35ffd701SAndroid Build Coastguard Worker Copyright(c) 2021 Intel Corporation
4*35ffd701SAndroid Build Coastguard Worker 
5*35ffd701SAndroid Build Coastguard Worker Permission is hereby granted, free of charge, to any person obtaining a
6*35ffd701SAndroid Build Coastguard Worker copy of this software and associated documentation files(the "Software"),
7*35ffd701SAndroid Build Coastguard Worker to deal in the Software without restriction, including without limitation
8*35ffd701SAndroid Build Coastguard Worker the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*35ffd701SAndroid Build Coastguard Worker and / or sell copies of the Software, and to permit persons to whom the
10*35ffd701SAndroid Build Coastguard Worker Software is furnished to do so, subject to the following conditions:
11*35ffd701SAndroid Build Coastguard Worker 
12*35ffd701SAndroid Build Coastguard Worker The above copyright notice and this permission notice shall be included
13*35ffd701SAndroid Build Coastguard Worker in all copies or substantial portions of the Software.
14*35ffd701SAndroid Build Coastguard Worker 
15*35ffd701SAndroid Build Coastguard Worker THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16*35ffd701SAndroid Build Coastguard Worker OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*35ffd701SAndroid Build Coastguard Worker FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18*35ffd701SAndroid Build Coastguard Worker THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19*35ffd701SAndroid Build Coastguard Worker OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20*35ffd701SAndroid Build Coastguard Worker ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21*35ffd701SAndroid Build Coastguard Worker OTHER DEALINGS IN THE SOFTWARE.
22*35ffd701SAndroid Build Coastguard Worker ============================= end_copyright_notice ===========================*/
23*35ffd701SAndroid Build Coastguard Worker #pragma once
24*35ffd701SAndroid Build Coastguard Worker 
25*35ffd701SAndroid Build Coastguard Worker #include "stdafx.h"
26*35ffd701SAndroid Build Coastguard Worker #include "GmmCommonULT.h"
27*35ffd701SAndroid Build Coastguard Worker #include "../inc/External/Common/GmmClientContext.h"
28*35ffd701SAndroid Build Coastguard Worker 
29*35ffd701SAndroid Build Coastguard Worker #define MAX_COUNT_PER_ADAPTER 5
30*35ffd701SAndroid Build Coastguard Worker 
31*35ffd701SAndroid Build Coastguard Worker #ifdef _WIN32
32*35ffd701SAndroid Build Coastguard Worker #define GMM_DLL_HANDLE      HINSTANCE
33*35ffd701SAndroid Build Coastguard Worker #else
34*35ffd701SAndroid Build Coastguard Worker #define GMM_DLL_HANDLE      void*
35*35ffd701SAndroid Build Coastguard Worker #endif
36*35ffd701SAndroid Build Coastguard Worker 
37*35ffd701SAndroid Build Coastguard Worker typedef struct GmmULTInfo_Rec
38*35ffd701SAndroid Build Coastguard Worker {
39*35ffd701SAndroid Build Coastguard Worker     ADAPTER_INFO       *pGfxAdapterInfo;
40*35ffd701SAndroid Build Coastguard Worker     PLATFORM            GfxPlatform;
41*35ffd701SAndroid Build Coastguard Worker     GMM_LIB_CONTEXT    *pLibContext;
42*35ffd701SAndroid Build Coastguard Worker     GMM_CLIENT_CONTEXT *pGmmULTClientContext;
43*35ffd701SAndroid Build Coastguard Worker     GMM_INIT_IN_ARGS    InArgs;
44*35ffd701SAndroid Build Coastguard Worker     GMM_INIT_OUT_ARGS   OutArgs;
45*35ffd701SAndroid Build Coastguard Worker } GmmULTInfo;
46*35ffd701SAndroid Build Coastguard Worker 
47*35ffd701SAndroid Build Coastguard Worker class MACommonULT : public testing::Test
48*35ffd701SAndroid Build Coastguard Worker {
49*35ffd701SAndroid Build Coastguard Worker public:
50*35ffd701SAndroid Build Coastguard Worker     MACommonULT();
51*35ffd701SAndroid Build Coastguard Worker     ~MACommonULT();
52*35ffd701SAndroid Build Coastguard Worker 
53*35ffd701SAndroid Build Coastguard Worker     void LoadGmmDll();
54*35ffd701SAndroid Build Coastguard Worker     void UnLoadGmmDll();
55*35ffd701SAndroid Build Coastguard Worker     void GmmInitModule(uint32_t AdapterIdx, uint32_t CountIdx);
56*35ffd701SAndroid Build Coastguard Worker     void GmmDestroyModule(uint32_t AdapterIdx, uint32_t CountIdx);
57*35ffd701SAndroid Build Coastguard Worker 
58*35ffd701SAndroid Build Coastguard Worker     PRODUCT_FAMILY GetProductFamily(uint32_t AdapterIdx);
59*35ffd701SAndroid Build Coastguard Worker     GFXCORE_FAMILY GetRenderCoreFamily(uint32_t AdapterIdx);
60*35ffd701SAndroid Build Coastguard Worker     GMM_CLIENT     GetClientType(uint32_t CountIdx);
61*35ffd701SAndroid Build Coastguard Worker     ADAPTER_BDF    GetAdapterBDF(uint32_t AdapterIdx);
62*35ffd701SAndroid Build Coastguard Worker 
63*35ffd701SAndroid Build Coastguard Worker protected:
64*35ffd701SAndroid Build Coastguard Worker     GmmULTInfo GmmTestInfo[MAX_NUM_ADAPTERS][MAX_COUNT_PER_ADAPTER];
65*35ffd701SAndroid Build Coastguard Worker 
66*35ffd701SAndroid Build Coastguard Worker     GMM_DLL_HANDLE hGmmLib;
67*35ffd701SAndroid Build Coastguard Worker     PFNGMMINIT     pfnGmmInit;
68*35ffd701SAndroid Build Coastguard Worker     PFNGMMDESTROY  pfnGmmDestroy;
69*35ffd701SAndroid Build Coastguard Worker 
70*35ffd701SAndroid Build Coastguard Worker     // Array to store the adapter BDFs from simulated UMD, Save the adapter bdf in an array
71*35ffd701SAndroid Build Coastguard Worker     ADAPTER_BDF AdapterSaved[MAX_NUM_ADAPTERS];
72*35ffd701SAndroid Build Coastguard Worker };
73*35ffd701SAndroid Build Coastguard Worker 
74*35ffd701SAndroid Build Coastguard Worker typedef MACommonULT GMM_MA_ULT_CONTEXT;
75*35ffd701SAndroid Build Coastguard Worker 
76*35ffd701SAndroid Build Coastguard Worker typedef struct ThreadInParams_Rec
77*35ffd701SAndroid Build Coastguard Worker {
78*35ffd701SAndroid Build Coastguard Worker     uint32_t AdapterIdx;
79*35ffd701SAndroid Build Coastguard Worker     uint32_t CountIdx;
80*35ffd701SAndroid Build Coastguard Worker 
81*35ffd701SAndroid Build Coastguard Worker     GMM_MA_ULT_CONTEXT *MATestObj;
82*35ffd701SAndroid Build Coastguard Worker } ThreadInParams;
83*35ffd701SAndroid Build Coastguard Worker 
84*35ffd701SAndroid Build Coastguard Worker class CTestMA : public MACommonULT
85*35ffd701SAndroid Build Coastguard Worker {
86*35ffd701SAndroid Build Coastguard Worker public:
87*35ffd701SAndroid Build Coastguard Worker     CTestMA();
88*35ffd701SAndroid Build Coastguard Worker     ~CTestMA();
89*35ffd701SAndroid Build Coastguard Worker 
90*35ffd701SAndroid Build Coastguard Worker     void SetUp() override;
91*35ffd701SAndroid Build Coastguard Worker     void TearDown() override;
92*35ffd701SAndroid Build Coastguard Worker 
93*35ffd701SAndroid Build Coastguard Worker     static void SetUpTestCase();
94*35ffd701SAndroid Build Coastguard Worker     static void TearDownTestCase();
95*35ffd701SAndroid Build Coastguard Worker };
96*35ffd701SAndroid Build Coastguard Worker 
97*35ffd701SAndroid Build Coastguard Worker #ifdef _WIN32
98*35ffd701SAndroid Build Coastguard Worker DWORD WINAPI MAULTThreadEntryFunc(LPVOID lpParam);
99*35ffd701SAndroid Build Coastguard Worker #else
100*35ffd701SAndroid Build Coastguard Worker void *MAULTThreadEntryFunc(void *lpParam);
101*35ffd701SAndroid Build Coastguard Worker #endif
102