-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63341b8
commit c320040
Showing
3 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/tt_metal/tt_metal/dispatch/dispatch_program/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...metal/dispatch/dispatch_program/test_dispatch_program_with_kernel_created_from_string.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "core_coord.hpp" | ||
#include "detail/tt_metal.hpp" | ||
#include "host_api.hpp" | ||
#include "impl/device/device.hpp" | ||
#include "impl/kernels/data_types.hpp" | ||
#include "impl/kernels/kernel_types.hpp" | ||
#include "impl/program/program.hpp" | ||
#include "tt_cluster_descriptor_types.h" | ||
|
||
#include "tests/tt_metal/tt_metal/common/dispatch_fixture.hpp" | ||
|
||
TEST_F(ProgramWithKernelCreatedFromStringFixture, TensixDataMovementKernel) { | ||
const CoreRange cores({0, 0}, {1, 1}); | ||
const string &kernel_src_code = R"( | ||
#include "debug/dprint.h" | ||
#include "dataflow_api.h" | ||
void kernel_main() { | ||
DPRINT_DATA0(DPRINT << "Hello, I am running a void data movement kernel on NOC 0." << ENDL()); | ||
DPRINT_DATA1(DPRINT << "Hello, I am running a void data movement kernel on NOC 1." << ENDL()); | ||
} | ||
)"; | ||
|
||
for (Device *device : this->devices_) { | ||
Program program = CreateProgram(); | ||
tt_metal::CreateKernelFromString( | ||
program, | ||
kernel_src_code, | ||
cores, | ||
tt_metal::DataMovementConfig{.processor = DataMovementProcessor::RISCV_1, .noc = NOC::RISCV_1_default}); | ||
this->RunProgram(device, program); | ||
}; | ||
} | ||
|
||
TEST_F(ProgramWithKernelCreatedFromStringFixture, TensixComputeKernel) { | ||
const CoreRange cores({0, 0}, {1, 1}); | ||
const string &kernel_src_code = R"( | ||
#include "debug/dprint.h" | ||
#include "compute_kernel_api.h" | ||
namespace NAMESPACE { | ||
void MAIN { | ||
DPRINT_MATH(DPRINT << "Hello, I am running a void compute kernel." << ENDL()); | ||
} | ||
} | ||
)"; | ||
|
||
for (Device *device : this->devices_) { | ||
Program program = CreateProgram(); | ||
tt_metal::CreateKernelFromString( | ||
program, | ||
kernel_src_code, | ||
cores, | ||
tt_metal::ComputeConfig{ | ||
.math_fidelity = MathFidelity::HiFi4, | ||
.fp32_dest_acc_en = false, | ||
.math_approx_mode = false, | ||
.compile_args = {}}); | ||
this->RunProgram(device, program); | ||
}; | ||
} | ||
|
||
TEST_F(ProgramWithKernelCreatedFromStringFixture, ActiveEthEthernetKernel) { | ||
const string &kernel_src_code = R"( | ||
#include "debug/dprint.h" | ||
#include "dataflow_api.h" | ||
void kernel_main() { | ||
DPRINT << "Hello, I am running a void ethernet kernel." << ENDL(); | ||
} | ||
)"; | ||
|
||
for (Device *device : this->devices_) { | ||
const std::unordered_set<CoreCoord> &active_ethernet_cores = device->get_active_ethernet_cores(true); | ||
if (active_ethernet_cores.empty()) { | ||
const chip_id_t device_id = device->id(); | ||
log_info(LogTest, "Skipping this test on device {} because it has no active ethernet cores.", device_id); | ||
continue; | ||
} | ||
Program program = CreateProgram(); | ||
tt_metal::CreateKernelFromString( | ||
program, | ||
kernel_src_code, | ||
*active_ethernet_cores.begin(), | ||
tt_metal::EthernetConfig{.noc = tt_metal::NOC::NOC_0}); | ||
this->RunProgram(device, program); | ||
}; | ||
} |