已合并
change(ccu): change COMM_ENGINE_CCU value from ccu to cpu #198
tlq_27创建于 9月20日
change(ccu): change COMM_ENGINE_CCU value from ccu to cpu #198
已合并
共 3 个文件变更+86-35
| @@ -82,9 +82,10 @@ typedef struct { | |||
| 82 | typedef CcuResult ccu_result; | 82 | typedef CcuResult ccu_result; |
| 83 | 83 | ||
| 84 | extern ccu_result asccomm_ccu_host_kernel_launch( | 84 | extern ccu_result asccomm_ccu_host_kernel_launch( |
| 85 | - const void* kernel_func, const asccomm_launch_kernel_cfg* cfg, void* args); | 85 | + const void* kernel_func, const char* kernel_name, const asccomm_launch_kernel_cfg* cfg, void* args); |
| 86 | 86 | ||
| 87 | -extern CcuResult HcommCcuHostKernelLaunch(const void* kernel_func, const HcommLaunchKernelCfg* cfg, void* args); | 87 | +extern CcuResult HcommCcuHostKernelLaunch( |
| 88 | + const void* kernel_func, const char* kernel_name, const HcommLaunchKernelCfg* cfg, void* args); | ||
| 88 | 89 | ||
| 89 | extern uint64_t HcommCcuGetLaunchHashTag(const char* tag); | 90 | extern uint64_t HcommCcuGetLaunchHashTag(const char* tag); |
| 90 | extern uint64_t asccomm_ccu_get_launch_hash_tag(const char* tag); | 91 | extern uint64_t asccomm_ccu_get_launch_hash_tag(const char* tag); |
| @@ -28,7 +28,7 @@ typedef void* CcuKernelArg; | |||
| 28 | typedef uint64_t ThreadHandle; | 28 | typedef uint64_t ThreadHandle; |
| 29 | typedef int32_t CommEngine; | 29 | typedef int32_t CommEngine; |
| 30 | typedef int32_t HcommResult; | 30 | typedef int32_t HcommResult; |
| 31 | -constexpr CommEngine COMM_ENGINE_CCU = static_cast<CommEngine>(5); | 31 | +constexpr CommEngine COMM_ENGINE_CCU = static_cast<CommEngine>(0); |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | extern "C" { | 34 | extern "C" { |
| @@ -105,7 +105,8 @@ struct VoidKernelRegisterCtx { | |||
| 105 | CcuResult VoidKernelTrampoline(CcuKernelArg arg); | 105 | CcuResult VoidKernelTrampoline(CcuKernelArg arg); |
| 106 | 106 | ||
| 107 | CcuResult RegisterCcuKernel( | 107 | CcuResult RegisterCcuKernel( |
| 108 | - const void* kernelFunc, const asccomm_launch_kernel_cfg* cfg, void* args, CcuKernelHandle& kernelHandle) | 108 | + const void* kernelFunc, const char* kernelName, const asccomm_launch_kernel_cfg* cfg, void* args, |
| 109 | + CcuKernelHandle& kernelHandle) | ||
| 109 | { | 110 | { |
| 110 | CcuResult ret = HcommCcuKernelRegisterStart(cfg->ccu_ins); | 111 | CcuResult ret = HcommCcuKernelRegisterStart(cfg->ccu_ins); |
| 111 | if (ret != CCU_SUCCESS) { | 112 | if (ret != CCU_SUCCESS) { |
| @@ -121,8 +122,9 @@ CcuResult RegisterCcuKernel( | |||
| 121 | const void* kernelArgs[] = {®isterCtx}; | 122 | const void* kernelArgs[] = {®isterCtx}; |
| 122 | 123 | ||
| 123 | // kernelFunc do not support func that return void , only support return CcuResult | 124 | // kernelFunc do not support func that return void , only support return CcuResult |
| 125 | + // kernelName非空时透传给注册侧(profiling名称等), 为空时注册侧使用默认名称 | ||
| 124 | ret = HcommCcuKernelRegister( | 126 | ret = HcommCcuKernelRegister( |
| 125 | - cfg->ccu_ins, dieId, nullptr, reinterpret_cast<const void*>(VoidKernelTrampoline), kernelArgs, 1, | 127 | + cfg->ccu_ins, dieId, kernelName, reinterpret_cast<const void*>(VoidKernelTrampoline), kernelArgs, 1, |
| 126 | &kernelHandle); | 128 | &kernelHandle); |
| 127 | if (ret != CCU_SUCCESS) { | 129 | if (ret != CCU_SUCCESS) { |
| 128 | (void)HcommCcuKernelRegisterEnd(cfg->ccu_ins); | 130 | (void)HcommCcuKernelRegisterEnd(cfg->ccu_ins); |
| @@ -135,12 +137,12 @@ CcuResult RegisterCcuKernel( | |||
| 135 | class KernelHandleCache { | 137 | class KernelHandleCache { |
| 136 | public: | 138 | public: |
| 137 | CcuResult Match( | 139 | CcuResult Match( |
| 138 | - const void* kernelFunc, const asccomm_launch_kernel_cfg* cfg, void* args, CcuKernelHandle& kernelHandle, | 140 | + const void* kernelFunc, const char* kernelName, const asccomm_launch_kernel_cfg* cfg, void* args, |
| 139 | - uint32_t& taskArgsNum) | 141 | + CcuKernelHandle& kernelHandle, uint32_t& taskArgsNum) |
| 140 | { | 142 | { |
| 141 | const uint64_t cacheTag = cfg->ccu_schd.binary_cache_tag; | 143 | const uint64_t cacheTag = cfg->ccu_schd.binary_cache_tag; |
| 142 | if (cacheTag == 0U) { | 144 | if (cacheTag == 0U) { |
| 143 | - return RegisterAndGetTaskArgsNum(kernelFunc, cfg, args, kernelHandle, taskArgsNum); | 145 | + return RegisterAndGetTaskArgsNum(kernelFunc, kernelName, cfg, args, kernelHandle, taskArgsNum); |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | std::lock_guard<std::mutex> lock(mutex_); | 148 | std::lock_guard<std::mutex> lock(mutex_); |
| @@ -150,7 +152,7 @@ public: | |||
| 150 | return HcommCcuGetTaskArgsNum(kernelHandle, &taskArgsNum); | 152 | return HcommCcuGetTaskArgsNum(kernelHandle, &taskArgsNum); |
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | - CcuResult ret = RegisterAndGetTaskArgsNum(kernelFunc, cfg, args, kernelHandle, taskArgsNum); | 155 | + CcuResult ret = RegisterAndGetTaskArgsNum(kernelFunc, kernelName, cfg, args, kernelHandle, taskArgsNum); |
| 154 | if (ret != CCU_SUCCESS) { | 156 | if (ret != CCU_SUCCESS) { |
| 155 | return ret; | 157 | return ret; |
| 156 | } | 158 | } |
| @@ -160,10 +162,10 @@ public: | |||
| 160 | 162 | ||
| 161 | private: | 163 | private: |
| 162 | CcuResult RegisterAndGetTaskArgsNum( | 164 | CcuResult RegisterAndGetTaskArgsNum( |
| 163 | - const void* kernelFunc, const asccomm_launch_kernel_cfg* cfg, void* args, CcuKernelHandle& kernelHandle, | 165 | + const void* kernelFunc, const char* kernelName, const asccomm_launch_kernel_cfg* cfg, void* args, |
| 164 | - uint32_t& taskArgsNum) | 166 | + CcuKernelHandle& kernelHandle, uint32_t& taskArgsNum) |
| 165 | { | 167 | { |
| 166 | - CcuResult ret = RegisterCcuKernel(kernelFunc, cfg, args, kernelHandle); | 168 | + CcuResult ret = RegisterCcuKernel(kernelFunc, kernelName, cfg, args, kernelHandle); |
| 167 | if (ret != CCU_SUCCESS) { | 169 | if (ret != CCU_SUCCESS) { |
| 168 | return ret; | 170 | return ret; |
| 169 | } | 171 | } |
| @@ -292,7 +294,7 @@ extern "C" uint64_t asccomm_ccu_get_launch_hash_tag(const char* tag) | |||
| 292 | } | 294 | } |
| 293 | 295 | ||
| 294 | extern "C" ccu_result asccomm_ccu_host_kernel_launch( | 296 | extern "C" ccu_result asccomm_ccu_host_kernel_launch( |
| 295 | - const void* kernel_func, const asccomm_launch_kernel_cfg* cfg, void* args) | 297 | + const void* kernel_func, const char* kernel_name, const asccomm_launch_kernel_cfg* cfg, void* args) |
| 296 | { | 298 | { |
| 297 | if (kernel_func == nullptr || cfg == nullptr || args == nullptr) { | 299 | if (kernel_func == nullptr || cfg == nullptr || args == nullptr) { |
| 298 | return CCU_E_PTR; | 300 | return CCU_E_PTR; |
| @@ -307,7 +309,7 @@ extern "C" ccu_result asccomm_ccu_host_kernel_launch( | |||
| 307 | 309 | ||
| 308 | CcuKernelHandle kernelHandle = 0; | 310 | CcuKernelHandle kernelHandle = 0; |
| 309 | uint32_t taskArgsNum = 0; | 311 | uint32_t taskArgsNum = 0; |
| 310 | - ret = GetKernelHandleCache().Match(kernel_func, cfg, args, kernelHandle, taskArgsNum); | 312 | + ret = GetKernelHandleCache().Match(kernel_func, kernel_name, cfg, args, kernelHandle, taskArgsNum); |
| 311 | if (ret != CCU_SUCCESS) { | 313 | if (ret != CCU_SUCCESS) { |
| 312 | return ret; | 314 | return ret; |
| 313 | } | 315 | } |
| @@ -315,10 +317,11 @@ extern "C" ccu_result asccomm_ccu_host_kernel_launch( | |||
| 315 | return LaunchCcuKernelWithStream(kernelHandle, args, taskArgsNum, cfg->stream); | 317 | return LaunchCcuKernelWithStream(kernelHandle, args, taskArgsNum, cfg->stream); |
| 316 | } | 318 | } |
| 317 | 319 | ||
| 318 | -extern "C" CcuResult HcommCcuHostKernelLaunch(const void* kernel_func, const HcommLaunchKernelCfg* cfg, void* args) | 320 | +extern "C" CcuResult HcommCcuHostKernelLaunch( |
| 321 | + const void* kernel_func, const char* kernel_name, const HcommLaunchKernelCfg* cfg, void* args) | ||
| 319 | { | 322 | { |
| 320 | if (cfg == nullptr) { | 323 | if (cfg == nullptr) { |
| 321 | - return asccomm_ccu_host_kernel_launch(kernel_func, nullptr, args); | 324 | + return asccomm_ccu_host_kernel_launch(kernel_func, kernel_name, nullptr, args); |
| 322 | } | 325 | } |
| 323 | 326 | ||
| 324 | asccomm_launch_kernel_cfg asccommCfg{}; | 327 | asccomm_launch_kernel_cfg asccommCfg{}; |
| @@ -329,7 +332,7 @@ extern "C" CcuResult HcommCcuHostKernelLaunch(const void* kernel_func, const Hco | |||
| 329 | asccommCfg.ccu_ins = cfg->ccuIns; | 332 | asccommCfg.ccu_ins = cfg->ccuIns; |
| 330 | asccommCfg.stream = cfg->stream; | 333 | asccommCfg.stream = cfg->stream; |
| 331 | asccommCfg.attrs = cfg->attrs; | 334 | asccommCfg.attrs = cfg->attrs; |
| 332 | - return asccomm_ccu_host_kernel_launch(kernel_func, &asccommCfg, args); | 335 | + return asccomm_ccu_host_kernel_launch(kernel_func, kernel_name, &asccommCfg, args); |
| 333 | } | 336 | } |
| 334 | 337 | ||
| 335 | extern "C" uint64_t HcommCcuGetLaunchHashTag(const char* tag) { return asccomm_ccu_get_launch_hash_tag(tag); } | 338 | extern "C" uint64_t HcommCcuGetLaunchHashTag(const char* tag) { return asccomm_ccu_get_launch_hash_tag(tag); } |
| @@ -28,12 +28,15 @@ CcuKernelHandle g_observedLaunchKernel = 0; | |||
| 28 | const void* g_observedLaunchArgs = nullptr; | 28 | const void* g_observedLaunchArgs = nullptr; |
| 29 | uint32_t g_observedLaunchArgNum = 0; | 29 | uint32_t g_observedLaunchArgNum = 0; |
| 30 | uint32_t g_taskArgsNum = 3; | 30 | uint32_t g_taskArgsNum = 3; |
| 31 | +const char* g_observedRegisterKernelName = nullptr; | ||
| 31 | CcuResult g_kernelLaunchResult = CCU_SUCCESS; | 32 | CcuResult g_kernelLaunchResult = CCU_SUCCESS; |
| 32 | HcommResult g_threadAllocResult = HCCL_SUCCESS; | 33 | HcommResult g_threadAllocResult = HCCL_SUCCESS; |
| 33 | HcommResult g_threadFreeResult = HCCL_SUCCESS; | 34 | HcommResult g_threadFreeResult = HCCL_SUCCESS; |
| 34 | 35 | ||
| 35 | void DummyKernel(void*) {} | 36 | void DummyKernel(void*) {} |
| 36 | 37 | ||
| 38 | +constexpr const char* DUMMY_KERNEL_NAME = "DummyKernel"; | ||
| 39 | + | ||
| 37 | asccomm_launch_kernel_cfg MakeLaunchCfg() | 40 | asccomm_launch_kernel_cfg MakeLaunchCfg() |
| 38 | { | 41 | { |
| 39 | asccomm_launch_kernel_cfg cfg{}; | 42 | asccomm_launch_kernel_cfg cfg{}; |
| @@ -52,8 +55,9 @@ extern "C" CcuResult HcommCcuKernelRegisterStart(CcuInsHandle) | |||
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | extern "C" CcuResult HcommCcuKernelRegister( | 57 | extern "C" CcuResult HcommCcuKernelRegister( |
| 55 | - CcuInsHandle, uint32_t, const char*, const void*, const void**, uint32_t, CcuKernelHandle* kernelHandle) | 58 | + CcuInsHandle, uint32_t, const char* kernelName, const void*, const void**, uint32_t, CcuKernelHandle* kernelHandle) |
| 56 | { | 59 | { |
| 60 | + g_observedRegisterKernelName = kernelName; | ||
| 57 | if (kernelHandle == nullptr) { | 61 | if (kernelHandle == nullptr) { |
| 58 | return CCU_E_PTR; | 62 | return CCU_E_PTR; |
| 59 | } | 63 | } |
| @@ -114,6 +118,7 @@ protected: | |||
| 114 | g_observedLaunchKernel = 0; | 118 | g_observedLaunchKernel = 0; |
| 115 | g_observedLaunchArgs = nullptr; | 119 | g_observedLaunchArgs = nullptr; |
| 116 | g_observedLaunchArgNum = 0; | 120 | g_observedLaunchArgNum = 0; |
| 121 | + g_observedRegisterKernelName = nullptr; | ||
| 117 | g_taskArgsNum = 3; | 122 | g_taskArgsNum = 3; |
| 118 | g_kernelLaunchResult = CCU_SUCCESS; | 123 | g_kernelLaunchResult = CCU_SUCCESS; |
| 119 | g_threadAllocResult = HCCL_SUCCESS; | 124 | g_threadAllocResult = HCCL_SUCCESS; |
| @@ -126,10 +131,16 @@ TEST_F(TestCcuHostLaunch, NullArgumentsReturnPtr) | |||
| 126 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); | 131 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); |
| 127 | uint64_t args[] = {1, 2, 3}; | 132 | uint64_t args[] = {1, 2, 3}; |
| 128 | 133 | ||
| 129 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(nullptr, &cfg, args), CCU_E_PTR); | 134 | + EXPECT_EQ(asccomm_ccu_host_kernel_launch(nullptr, DUMMY_KERNEL_NAME, &cfg, args), CCU_E_PTR); |
| 130 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), nullptr, args), CCU_E_PTR); | 135 | + EXPECT_EQ( |
| 131 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, nullptr), CCU_E_PTR); | 136 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, nullptr, args), |
| 132 | - EXPECT_EQ(HcommCcuHostKernelLaunch(reinterpret_cast<const void*>(DummyKernel), nullptr, args), CCU_E_PTR); | 137 | + CCU_E_PTR); |
| 138 | + EXPECT_EQ( | ||
| 139 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, nullptr), | ||
| 140 | + CCU_E_PTR); | ||
| 141 | + EXPECT_EQ( | ||
| 142 | + HcommCcuHostKernelLaunch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, nullptr, args), | ||
| 143 | + CCU_E_PTR); | ||
| 133 | } | 144 | } |
| 134 | 145 | ||
| 135 | TEST_F(TestCcuHostLaunch, UnsupportedDieMaskReturnsPara) | 146 | TEST_F(TestCcuHostLaunch, UnsupportedDieMaskReturnsPara) |
| @@ -138,10 +149,14 @@ TEST_F(TestCcuHostLaunch, UnsupportedDieMaskReturnsPara) | |||
| 138 | uint64_t args[] = {1, 2, 3}; | 149 | uint64_t args[] = {1, 2, 3}; |
| 139 | 150 | ||
| 140 | cfg.ccu_schd.phy_die_mask = 0; | 151 | cfg.ccu_schd.phy_die_mask = 0; |
| 141 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_PARA); | 152 | + EXPECT_EQ( |
| 153 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 154 | + CCU_E_PARA); | ||
| 142 | 155 | ||
| 143 | cfg.ccu_schd.phy_die_mask = 0x03; | 156 | cfg.ccu_schd.phy_die_mask = 0x03; |
| 144 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_PARA); | 157 | + EXPECT_EQ( |
| 158 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 159 | + CCU_E_PARA); | ||
| 145 | 160 | ||
| 146 | HcommLaunchKernelCfg hcommCfg{}; | 161 | HcommLaunchKernelCfg hcommCfg{}; |
| 147 | hcommCfg.ccuSchd.numBlocks = cfg.ccu_schd.num_blocks; | 162 | hcommCfg.ccuSchd.numBlocks = cfg.ccu_schd.num_blocks; |
| @@ -151,7 +166,9 @@ TEST_F(TestCcuHostLaunch, UnsupportedDieMaskReturnsPara) | |||
| 151 | hcommCfg.ccuIns = cfg.ccu_ins; | 166 | hcommCfg.ccuIns = cfg.ccu_ins; |
| 152 | hcommCfg.stream = cfg.stream; | 167 | hcommCfg.stream = cfg.stream; |
| 153 | hcommCfg.attrs = cfg.attrs; | 168 | hcommCfg.attrs = cfg.attrs; |
| 154 | - EXPECT_EQ(HcommCcuHostKernelLaunch(reinterpret_cast<const void*>(DummyKernel), &hcommCfg, args), CCU_E_PARA); | 169 | + EXPECT_EQ( |
| 170 | + HcommCcuHostKernelLaunch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &hcommCfg, args), | ||
| 171 | + CCU_E_PARA); | ||
| 155 | } | 172 | } |
| 156 | 173 | ||
| 157 | TEST_F(TestCcuHostLaunch, UnsupportedNumBlocksReturnsPara) | 174 | TEST_F(TestCcuHostLaunch, UnsupportedNumBlocksReturnsPara) |
| @@ -160,10 +177,14 @@ TEST_F(TestCcuHostLaunch, UnsupportedNumBlocksReturnsPara) | |||
| 160 | uint64_t args[] = {1, 2, 3}; | 177 | uint64_t args[] = {1, 2, 3}; |
| 161 | 178 | ||
| 162 | cfg.ccu_schd.num_blocks = 0; | 179 | cfg.ccu_schd.num_blocks = 0; |
| 163 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_PARA); | 180 | + EXPECT_EQ( |
| 181 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 182 | + CCU_E_PARA); | ||
| 164 | 183 | ||
| 165 | cfg.ccu_schd.num_blocks = 2; | 184 | cfg.ccu_schd.num_blocks = 2; |
| 166 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_PARA); | 185 | + EXPECT_EQ( |
| 186 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 187 | + CCU_E_PARA); | ||
| 167 | } | 188 | } |
| 168 | 189 | ||
| 169 | TEST_F(TestCcuHostLaunch, LaunchUsesAllocatedThreadAndHcommKernelLaunch) | 190 | TEST_F(TestCcuHostLaunch, LaunchUsesAllocatedThreadAndHcommKernelLaunch) |
| @@ -171,7 +192,9 @@ TEST_F(TestCcuHostLaunch, LaunchUsesAllocatedThreadAndHcommKernelLaunch) | |||
| 171 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); | 192 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); |
| 172 | uint64_t args[] = {1, 2, 3}; | 193 | uint64_t args[] = {1, 2, 3}; |
| 173 | 194 | ||
| 174 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_SUCCESS); | 195 | + EXPECT_EQ( |
| 196 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 197 | + CCU_SUCCESS); | ||
| 175 | EXPECT_EQ(g_threadAllocCallCount, 1U); | 198 | EXPECT_EQ(g_threadAllocCallCount, 1U); |
| 176 | EXPECT_EQ(g_observedThreadEngine, COMM_ENGINE_CCU); | 199 | EXPECT_EQ(g_observedThreadEngine, COMM_ENGINE_CCU); |
| 177 | EXPECT_EQ(g_observedThreadStream, cfg.stream); | 200 | EXPECT_EQ(g_observedThreadStream, cfg.stream); |
| @@ -180,9 +203,21 @@ TEST_F(TestCcuHostLaunch, LaunchUsesAllocatedThreadAndHcommKernelLaunch) | |||
| 180 | EXPECT_NE(g_observedLaunchKernel, 0U); | 203 | EXPECT_NE(g_observedLaunchKernel, 0U); |
| 181 | EXPECT_EQ(g_observedLaunchArgs, args); | 204 | EXPECT_EQ(g_observedLaunchArgs, args); |
| 182 | EXPECT_EQ(g_observedLaunchArgNum, 3U); | 205 | EXPECT_EQ(g_observedLaunchArgNum, 3U); |
| 206 | + EXPECT_EQ(g_observedRegisterKernelName, DUMMY_KERNEL_NAME); | ||
| 183 | EXPECT_EQ(g_threadFreeCallCount, 0U); | 207 | EXPECT_EQ(g_threadFreeCallCount, 0U); |
| 184 | } | 208 | } |
| 185 | 209 | ||
| 210 | +TEST_F(TestCcuHostLaunch, NullKernelNameIsForwardedToRegister) | ||
| 211 | +{ | ||
| 212 | + asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); | ||
| 213 | + uint64_t args[] = {1, 2, 3}; | ||
| 214 | + | ||
| 215 | + EXPECT_EQ( | ||
| 216 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), nullptr, &cfg, args), CCU_SUCCESS); | ||
| 217 | + EXPECT_EQ(g_observedRegisterKernelName, nullptr); | ||
| 218 | + EXPECT_EQ(g_kernelLaunchCallCount, 1U); | ||
| 219 | +} | ||
| 220 | + | ||
| 186 | TEST_F(TestCcuHostLaunch, TooManyTaskArgsReturnsNotSupportBeforeThreadAllocation) | 221 | TEST_F(TestCcuHostLaunch, TooManyTaskArgsReturnsNotSupportBeforeThreadAllocation) |
| 187 | { | 222 | { |
| 188 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); | 223 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); |
| @@ -190,7 +225,8 @@ TEST_F(TestCcuHostLaunch, TooManyTaskArgsReturnsNotSupportBeforeThreadAllocation | |||
| 190 | g_taskArgsNum = 14; | 225 | g_taskArgsNum = 14; |
| 191 | 226 | ||
| 192 | EXPECT_EQ( | 227 | EXPECT_EQ( |
| 193 | - asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_NOT_SUPPORT); | 228 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), |
| 229 | + CCU_E_NOT_SUPPORT); | ||
| 194 | EXPECT_EQ(g_threadAllocCallCount, 0U); | 230 | EXPECT_EQ(g_threadAllocCallCount, 0U); |
| 195 | EXPECT_EQ(g_kernelLaunchCallCount, 0U); | 231 | EXPECT_EQ(g_kernelLaunchCallCount, 0U); |
| 196 | } | 232 | } |
| @@ -202,7 +238,9 @@ TEST_F(TestCcuHostLaunch, ThreadAllocationFailureStopsLaunch) | |||
| 202 | g_threadAllocResult = HCCL_E_UNAVAIL; | 238 | g_threadAllocResult = HCCL_E_UNAVAIL; |
| 203 | 239 | ||
| 204 | // MakeLaunchCfg uses a fresh stream, so this test does not reuse a cached handle. | 240 | // MakeLaunchCfg uses a fresh stream, so this test does not reuse a cached handle. |
| 205 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_UNAVAIL); | 241 | + EXPECT_EQ( |
| 242 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 243 | + CCU_E_UNAVAIL); | ||
| 206 | EXPECT_EQ(g_kernelLaunchCallCount, 0U); | 244 | EXPECT_EQ(g_kernelLaunchCallCount, 0U); |
| 207 | EXPECT_EQ(g_threadFreeCallCount, 0U); | 245 | EXPECT_EQ(g_threadFreeCallCount, 0U); |
| 208 | } | 246 | } |
| @@ -213,7 +251,9 @@ TEST_F(TestCcuHostLaunch, KernelLaunchFailureKeepsThreadAlive) | |||
| 213 | uint64_t args[] = {1, 2, 3}; | 251 | uint64_t args[] = {1, 2, 3}; |
| 214 | g_kernelLaunchResult = CCU_E_RUNTIME; | 252 | g_kernelLaunchResult = CCU_E_RUNTIME; |
| 215 | 253 | ||
| 216 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_E_RUNTIME); | 254 | + EXPECT_EQ( |
| 255 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 256 | + CCU_E_RUNTIME); | ||
| 217 | EXPECT_EQ(g_kernelLaunchCallCount, 1U); | 257 | EXPECT_EQ(g_kernelLaunchCallCount, 1U); |
| 218 | EXPECT_EQ(g_threadFreeCallCount, 0U); | 258 | EXPECT_EQ(g_threadFreeCallCount, 0U); |
| 219 | } | 259 | } |
| @@ -223,8 +263,12 @@ TEST_F(TestCcuHostLaunch, RepeatedLaunchesAllocateAndFreeIndependentThreads) | |||
| 223 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); | 263 | asccomm_launch_kernel_cfg cfg = MakeLaunchCfg(); |
| 224 | uint64_t args[] = {1, 2, 3}; | 264 | uint64_t args[] = {1, 2, 3}; |
| 225 | 265 | ||
| 226 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_SUCCESS); | 266 | + EXPECT_EQ( |
| 227 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &cfg, args), CCU_SUCCESS); | 267 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), |
| 268 | + CCU_SUCCESS); | ||
| 269 | + EXPECT_EQ( | ||
| 270 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &cfg, args), | ||
| 271 | + CCU_SUCCESS); | ||
| 228 | EXPECT_EQ(g_threadAllocCallCount, 1U); | 272 | EXPECT_EQ(g_threadAllocCallCount, 1U); |
| 229 | EXPECT_EQ(g_kernelLaunchCallCount, 2U); | 273 | EXPECT_EQ(g_kernelLaunchCallCount, 2U); |
| 230 | EXPECT_EQ(g_threadFreeCallCount, 0U); | 274 | EXPECT_EQ(g_threadFreeCallCount, 0U); |
| @@ -236,9 +280,12 @@ TEST_F(TestCcuHostLaunch, DifferentStreamsUseIndependentThreads) | |||
| 236 | asccomm_launch_kernel_cfg secondCfg = MakeLaunchCfg(); | 280 | asccomm_launch_kernel_cfg secondCfg = MakeLaunchCfg(); |
| 237 | uint64_t args[] = {1, 2, 3}; | 281 | uint64_t args[] = {1, 2, 3}; |
| 238 | 282 | ||
| 239 | - EXPECT_EQ(asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &firstCfg, args), CCU_SUCCESS); | ||
| 240 | EXPECT_EQ( | 283 | EXPECT_EQ( |
| 241 | - asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), &secondCfg, args), CCU_SUCCESS); | 284 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &firstCfg, args), |
| 285 | + CCU_SUCCESS); | ||
| 286 | + EXPECT_EQ( | ||
| 287 | + asccomm_ccu_host_kernel_launch(reinterpret_cast<const void*>(DummyKernel), DUMMY_KERNEL_NAME, &secondCfg, args), | ||
| 288 | + CCU_SUCCESS); | ||
| 242 | EXPECT_EQ(g_threadAllocCallCount, 2U); | 289 | EXPECT_EQ(g_threadAllocCallCount, 2U); |
| 243 | EXPECT_EQ(g_kernelLaunchCallCount, 2U); | 290 | EXPECT_EQ(g_kernelLaunchCallCount, 2U); |
| 244 | EXPECT_EQ(g_threadFreeCallCount, 0U); | 291 | EXPECT_EQ(g_threadFreeCallCount, 0U); |