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