kfdtest: Update KFDMultiProcessTest class to support kfdtest run on multiple gpu
Update KFDMultiProcessTest class to fork process on gpu wise. Signed-off-by: Xiaogang Chen <Xiaogang.Chen@amd.com> Change-Id: Ibb12d64b4cbc5f082d737fd8d8a74233b75be13e
Этот коммит содержится в:
коммит произвёл
Xiaogang Chen
родитель
b4943d718b
Коммит
c69e660e7a
@@ -28,35 +28,51 @@
|
||||
#include <vector>
|
||||
#include "KFDBaseComponentTest.hpp"
|
||||
|
||||
extern unsigned int g_TestGPUsNum;
|
||||
|
||||
// @class KFDMultiProcessTest
|
||||
// Base class for tests forking multiple child processes
|
||||
class KFDMultiProcessTest : public KFDBaseComponentTest {
|
||||
public:
|
||||
KFDMultiProcessTest(void): m_ChildStatus(HSAKMT_STATUS_ERROR), m_IsParent(true) {}
|
||||
KFDMultiProcessTest(void) {
|
||||
for ( int i = 0; i < g_TestGPUsNum; i++) {
|
||||
m_ChildStatus[i] = HSAKMT_STATUS_ERROR;
|
||||
m_IsParent[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
~KFDMultiProcessTest(void) {
|
||||
if (!m_IsParent) {
|
||||
/* Child process has to exit
|
||||
* otherwise gtest will continue other tests
|
||||
*/
|
||||
exit(m_ChildStatus);
|
||||
for ( int i = 0; i < g_TestGPUsNum; i++) {
|
||||
if (!m_IsParent[i]) {
|
||||
/* Child process has to exit
|
||||
* otherwise gtest will continue other tests
|
||||
*/
|
||||
exit(m_ChildStatus[i]);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
WaitChildProcesses();
|
||||
} catch (...) {}
|
||||
const std::vector<int> gpuNodes = m_NodeInfo.GetNodesWithGPU();
|
||||
unsigned gpu_num = gpuNodes.size();
|
||||
int gpu_node;
|
||||
for (int i = 0; i < g_TestGPUsNum; i++) {
|
||||
gpu_node = gpuNodes.at(i);
|
||||
WaitChildProcesses(gpu_node);
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
void ForkChildProcesses(int nprocesses);
|
||||
void WaitChildProcesses();
|
||||
void ForkChildProcesses(unsigned int nodeId, int nprocesses);
|
||||
void WaitChildProcesses(unsigned int nodeId);
|
||||
|
||||
protected: // Members
|
||||
std::string m_psName;
|
||||
int m_ProcessIndex;
|
||||
std::vector<pid_t> m_ChildPids;
|
||||
HSAKMT_STATUS m_ChildStatus;
|
||||
bool m_IsParent;
|
||||
std::string m_psName[MAX_GPU];
|
||||
int m_ProcessIndex[MAX_GPU];
|
||||
std::vector<pid_t> m_ChildPids[MAX_GPU];
|
||||
HSAKMT_STATUS m_ChildStatus[MAX_GPU];
|
||||
bool m_IsParent[MAX_GPU];
|
||||
};
|
||||
|
||||
#endif // __KFD_MULTI_PROCESS_TEST__H__
|
||||
|
||||
Ссылка в новой задаче
Block a user