Skip to content

Commit ab39002

Browse files
author
Yakov Lipkovich
authored
Implement MessagePack backend (ROCm#904)
* Implement MessagePack backend * Install msgpack on Docker by adding Debian repo and installing from there * Revert "Install msgpack on Docker by adding Debian repo and installing from there" This reverts commit 94ae9de.
1 parent a93bc68 commit ab39002

38 files changed

+701
-188
lines changed

Diff for: HostLibraryTests/ContractionLibraryLoading_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using namespace Tensile;
3737
TEST(ContractionLibraryLoadingTest, MultipleKernels)
3838
{
3939
auto library = LoadLibraryFile<ContractionProblem>(
40-
TestData::Instance().file("SampleTensileKernels.yaml").native());
40+
TestData::Instance().file("SampleTensileKernels").native());
4141
ASSERT_NE(library, nullptr);
4242

4343
AMDGPU hardware;
@@ -87,7 +87,7 @@ TEST(ContractionLibraryLoadingTest, MultipleKernels)
8787

8888
TEST(ContractionLibraryLoadingTest, SGEMM_Kernels_Lite)
8989
{
90-
auto library = LoadLibraryFile<ContractionProblem>(
91-
TestData::Instance().file("KernelsLite.yaml").native());
90+
auto library
91+
= LoadLibraryFile<ContractionProblem>(TestData::Instance().file("KernelsLite").native());
9292
ASSERT_NE(library, nullptr);
9393
}

Diff for: HostLibraryTests/TestData_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ TEST(TestData, Simple)
3737
auto is_regular_file
3838
= static_cast<bool (*)(boost::filesystem::path const&)>(boost::filesystem::is_regular_file);
3939

40-
EXPECT_PRED1(is_regular_file, data.file("KernelsLite.yaml"));
40+
EXPECT_PRED1(is_regular_file, data.file("KernelsLite"));
4141
EXPECT_FALSE(is_regular_file(data.file("fjdlksljfjldskj")));
4242

43-
auto files = data.glob("*.yaml");
43+
auto files = data.glob(std::string("*.") + TestData::defaultExtension);
4444
EXPECT_EQ(files.size(), 6);
4545
for(auto file : files)
4646
{

Diff for: HostLibraryTests/configs/CMakeLists.txt

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
2-
set(SOLUTION_LIBRARY_FILES
3-
${SOLUTION_LIBRARY_FILES}
4-
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLite.yaml"
5-
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLiteMixed.yaml"
6-
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLiteNavi.yaml"
7-
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsTileLite.yaml"
8-
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/SampleTensileKernels.yaml"
9-
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/rocBLAS_Full.yaml"
10-
PARENT_SCOPE)
11-
1+
if(Tensile_YAML)
2+
set(SOLUTION_LIBRARY_FILES
3+
${SOLUTION_LIBRARY_FILES}
4+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLite.yaml"
5+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLiteMixed.yaml"
6+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLiteNavi.yaml"
7+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsTileLite.yaml"
8+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/SampleTensileKernels.yaml"
9+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/rocBLAS_Full.yaml"
10+
PARENT_SCOPE)
11+
else()
12+
set(SOLUTION_LIBRARY_FILES
13+
${SOLUTION_LIBRARY_FILES}
14+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLite.dat"
15+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLiteMixed.dat"
16+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsLiteNavi.dat"
17+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/KernelsTileLite.dat"
18+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/SampleTensileKernels.dat"
19+
"${CMAKE_CURRENT_SOURCE_DIR}/SolutionLibraries/rocBLAS_Full.dat"
20+
PARENT_SCOPE)
21+
endif()
897 KB
Binary file not shown.
1.42 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
54.3 MB
Binary file not shown.

Diff for: HostLibraryTests/hip/RunGEMMKernelTileSelection_test.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,20 @@ struct RunGEMMKernelSolutionSelectionTest : public ::testing::TestWithParam<Cont
176176
#endif
177177
}
178178

179-
void TearDown() override
180-
{
181-
hipFree(a_d);
182-
hipFree(b_d);
183-
hipFree(c_d);
184-
hipFree(d_d);
185-
hipFree(d_ref_d);
179+
}
186180

187-
hipDeviceReset();
188-
}
189-
};
181+
void TearDown() override
182+
{
183+
hipFree(a_d);
184+
hipFree(b_d);
185+
hipFree(c_d);
186+
hipFree(d_d);
187+
hipFree(d_ref_d);
188+
189+
hipDeviceReset();
190+
}
191+
}
192+
;
190193

191194
TEST_P(RunGEMMKernelSolutionSelectionTest, KernelsTileSelection)
192195
{
@@ -195,11 +198,11 @@ TEST_P(RunGEMMKernelSolutionSelectionTest, KernelsTileSelection)
195198
// std::cout << problem << std::endl;
196199

197200
auto library = LoadLibraryFile<ContractionProblem>(
198-
TestData::File("kernels_tile_selection/TensileLibrary.yaml").native());
201+
TestData::Instance().file("kernels_tile_selection/TensileLibrary").native());
199202

200203
hip::SolutionAdapter adapter(false);
201204
adapter.loadCodeObjectFile(
202-
TestData::File("kernels_tile_selection/TensileLibrary_gfx906.co").native());
205+
TestData::Instance().file("kernels_tile_selection/TensileLibrary_gfx906", "co").native());
203206

204207
ASSERT_NE(library, nullptr);
205208

Diff for: HostLibraryTests/hip/RunGEMMKernel_test.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ std::vector<std::tuple<std::shared_ptr<SolutionLibrary<ContractionProblem>>,
534534

535535
{
536536
auto library = LoadLibraryFile<ContractionProblem>(
537-
TestData::Instance().file("kernels_lite/TensileLibrary.yaml").native());
537+
TestData::Instance().file("kernels_lite/TensileLibrary").native());
538538
auto adapter = std::make_shared<hip::SolutionAdapter>(debug, "kernels_lite (file)");
539539
for(auto file : TestData::Instance().glob("kernels_lite/*.*co"))
540540
adapter->loadCodeObjectFile(file.native());
@@ -544,7 +544,7 @@ std::vector<std::tuple<std::shared_ptr<SolutionLibrary<ContractionProblem>>,
544544

545545
{
546546
auto library = LoadLibraryFile<ContractionProblem>(
547-
TestData::Instance().file("kernels_lite_mixed/TensileLibrary.yaml").native());
547+
TestData::Instance().file("kernels_lite_mixed/TensileLibrary").native());
548548
auto adapter = std::make_shared<hip::SolutionAdapter>(debug, "kernels_lite_mixed (file)");
549549
for(auto file : TestData::Instance().glob("kernels_lite_mixed/*.*co"))
550550
adapter->loadCodeObjectFile(file.native());
@@ -554,7 +554,7 @@ std::vector<std::tuple<std::shared_ptr<SolutionLibrary<ContractionProblem>>,
554554

555555
{
556556
auto library = LoadLibraryFile<ContractionProblem>(
557-
TestData::Instance().file("tile_aware_selection/library/TensileLibrary.yaml").native());
557+
TestData::Instance().file("tile_aware_selection/library/TensileLibrary").native());
558558

559559
auto adapter = std::make_shared<hip::SolutionAdapter>(debug, "tile_aware_selection");
560560
for(auto file : TestData::Instance().glob("tile_aware_selection/library/*.*co"))
@@ -569,8 +569,7 @@ std::vector<std::tuple<std::shared_ptr<SolutionLibrary<ContractionProblem>>,
569569
auto envDir = TestData::Env("TENSILE_TEST_LIBRARY");
570570
if(envDir)
571571
{
572-
auto library
573-
= LoadLibraryFile<ContractionProblem>(envDir.file("TensileLibrary.yaml").native());
572+
auto library = LoadLibraryFile<ContractionProblem>(envDir.file("TensileLibrary").native());
574573
auto adapter = std::make_shared<hip::SolutionAdapter>(debug, "TENSILE_TEST_LIBRARY");
575574

576575
for(auto file : envDir.glob("*.co"))

Diff for: HostLibraryTests/llvm/LibraryPerformance_test.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ using namespace Tensile;
3737
/**
3838
* LibraryPerformanceTest:
3939
*
40-
* This suite contains micro-benchmarks for pieces of the runtime library. It
41-
* does not exercise any of the Hip-specific code.
40+
* This suite contains micro-benchmarks for pieces of the runtime library. It does not
41+
* exercise any of the Hip-specific code.
4242
*
43-
* There are no performance-based assertions or checks. The timing results are
44-
* provided by googletest.
43+
* There are no performance-based assertions or checks. The timing results are provided by
44+
* googletest.
4545
*
46-
* Most of these tests depend on a library being loaded from a YAML file. The
47-
* library objects are cached so that the deserialization time is not a part of
48-
* the actual test (outside of the LoadLibrary test). PopulateCache is an empty
49-
* test whose purpose is to ensure the cache is populated for the actual tests.
46+
* Most of these tests depend on a library being loaded from a DAT/YAML file. The library objects
47+
* are cached so that the deserialization time is not a part of the actual test (outside of the
48+
* LoadLibrary test). PopulateCache is an empty test whose purpose is to ensure the cache is
49+
* populated for the actual tests.
5050
*/
5151
struct LibraryPerformanceTest
5252
: public ::testing::TestWithParam<std::tuple<AMDGPU, std::string, bool, bool>>
@@ -223,17 +223,17 @@ std::vector<LibraryPerformanceTest::ParamType> GetParams()
223223

224224
for(auto const& gpu : gpus)
225225
{
226-
rv.push_back(std::make_tuple(gpu, "KernelsLite.yaml", false, false));
227-
rv.push_back(std::make_tuple(gpu, "KernelsLiteMixed.yaml", false, true));
228-
rv.push_back(std::make_tuple(gpu, "KernelsLiteNavi.yaml", true, false));
229-
rv.push_back(std::make_tuple(gpu, "KernelsTileLite.yaml", false, false));
230-
rv.push_back(std::make_tuple(gpu, "rocBLAS_Full.yaml", false, true));
226+
rv.push_back(std::make_tuple(gpu, "KernelsLite", false, false));
227+
rv.push_back(std::make_tuple(gpu, "KernelsLiteMixed", false, true));
228+
rv.push_back(std::make_tuple(gpu, "KernelsLiteNavi", true, false));
229+
rv.push_back(std::make_tuple(gpu, "KernelsTileLite", false, false));
230+
rv.push_back(std::make_tuple(gpu, "rocBLAS_Full", false, true));
231231
}
232232

233233
rv.push_back(std::make_tuple(
234-
AMDGPU(AMDGPU::Processor::gfx908, 64, "Arcturus"), "rocBLAS_Full.yaml", false, true));
234+
AMDGPU(AMDGPU::Processor::gfx908, 64, "Arcturus"), "rocBLAS_Full", false, true));
235235
rv.push_back(std::make_tuple(
236-
AMDGPU(AMDGPU::Processor::gfx1010, 40, "Navi"), "KernelsLiteNavi.yaml", true, true));
236+
AMDGPU(AMDGPU::Processor::gfx1010, 40, "Navi"), "KernelsLiteNavi", true, true));
237237

238238
return rv;
239239
}

Diff for: HostLibraryTests/testlib/include/TestData.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ struct TestData : public Tensile::LazySingleton<TestData>
4141

4242
boost::filesystem::path dataDir() const;
4343

44-
boost::filesystem::path file(std::string const& filename) const;
44+
static const std::string defaultExtension;
45+
boost::filesystem::path file(std::string const& filename,
46+
std::string const& extension = defaultExtension) const;
4547

4648
std::vector<boost::filesystem::path> glob(std::string const& pattern) const;
4749

Diff for: HostLibraryTests/testlib/source/TestData.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939

4040
#include <Tensile/Utils.hpp>
4141

42+
#ifdef TENSILE_YAML
43+
const std::string TestData::defaultExtension = "yaml";
44+
#else
45+
const std::string TestData::defaultExtension = "dat";
46+
#endif
47+
4248
TestData::operator bool() const
4349
{
4450
return boost::filesystem::is_directory(dataDir());
@@ -64,9 +70,10 @@ boost::filesystem::path TestData::dataDir() const
6470
return m_dataDir;
6571
}
6672

67-
boost::filesystem::path TestData::file(std::string const& filename) const
73+
boost::filesystem::path TestData::file(std::string const& filename,
74+
std::string const& extension) const
6875
{
69-
return dataDir() / filename;
76+
return dataDir() / (filename + "." + extension);
7077
}
7178

7279
std::vector<boost::filesystem::path> TestData::glob(std::string const& pattern) const

Diff for: Tensile/BenchmarkProblems.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from . import ClientExecutable
3434
from . import SolutionLibrary
35-
from . import YAMLIO
35+
from . import LibraryIO
3636
from . import Utils
3737
from .BenchmarkStructs import BenchmarkProcess
3838
from .ClientWriter import runClient, writeClientParameters, writeClientConfig
@@ -362,7 +362,7 @@ def benchmarkProblemType( problemTypeConfig, problemSizeGroupConfig, \
362362
############################################################################
363363
# Write Solutions YAML
364364
############################################################################
365-
YAMLIO.writeSolutions(solutionsFileName, benchmarkStep.problemSizes, \
365+
LibraryIO.writeSolutions(solutionsFileName, benchmarkStep.problemSizes, \
366366
solutions )
367367

368368
# End Iteration
@@ -520,11 +520,12 @@ def writeBenchmarkFiles(stepBaseDir, solutions, problemSizes, stepName, filesToC
520520
globalParameters["WorkingPath"], globalParameters["CxxCompiler"], [problemType], solutions, kernels, kernelsBetaOnly, \
521521
solutionWriter, kernelWriterSource, kernelWriterAssembly, errorTolerant=True )
522522

523+
newLibraryFilename = "TensileLibrary.yaml" if globalParameters["YAML"] else "TensileLibrary.dat"
523524
newLibraryDir = ensurePath(os.path.join(globalParameters["WorkingPath"], 'library'))
524-
newLibraryFile = os.path.join(newLibraryDir, "TensileLibrary.yaml")
525+
newLibraryFile = os.path.join(newLibraryDir, newLibraryFilename)
525526
newLibrary = SolutionLibrary.MasterSolutionLibrary.BenchmarkingLibrary(solutions)
526527
newLibrary.applyNaming(kernelMinNaming)
527-
YAMLIO.write(newLibraryFile, Utils.state(newLibrary))
528+
LibraryIO.configWriter(globalParameters["YAML"]).write(newLibraryFile, Utils.state(newLibrary))
528529

529530
codeObjectFiles = [os.path.relpath(f, globalParameters["WorkingPath"]) for f in codeObjectFiles]
530531

Diff for: Tensile/ClientWriter.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .Common import globalParameters, HR, pushWorkingPath, popWorkingPath, print1, CHeader, printWarning, listToInitializer, ClientExecutionLock
2323
from . import ClientExecutable
2424
from . import Common
25-
from . import YAMLIO
25+
from . import LibraryIO
2626

2727
import os
2828
import subprocess
@@ -98,7 +98,7 @@ def main( config ):
9898
for logicFileName in logicFiles:
9999
(scheduleName, deviceNames, problemType, solutionsForType, \
100100
indexOrder, exactLogic, rangeLogic, newLibrary, architectureName) \
101-
= YAMLIO.readLibraryLogicForSchedule(logicFileName)
101+
= LibraryIO.readLibraryLogicForSchedule(logicFileName)
102102
if problemType["DataType"].isHalf():
103103
enableHalf = True
104104
functions.append((scheduleName, problemType))
@@ -559,7 +559,8 @@ def param(key, value):
559559
f.write("{}={}\n".format(key, value))
560560

561561
sourceDir = os.path.join(stepBaseDir, "source")
562-
libraryFile = os.path.join(sourceDir, "library", "TensileLibrary.yaml")
562+
libraryFilename = "TensileLibrary.yaml" if globalParameters["YAML"] else "TensileLibrary.dat"
563+
libraryFile = os.path.join(sourceDir, "library", libraryFilename)
563564
param("library-file", libraryFile)
564565

565566
currentGFXName = Common.gfxName(globalParameters["CurrentISA"])

Diff for: Tensile/Common.py

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
########################################
109109
globalParameters["CMakeBuildType"] = "Release" # whether benchmark clients and library client should be release or debug
110110
globalParameters["PrintSolutionRejectionReason"] = False # when a solution is marked as invalid, print why
111+
globalParameters["YAML"] = False # whether to use the YAML backend (as opposed to the MessagePack backend)
111112

112113
# how to initialize tensor data
113114
# serial-in-u will use a sequence that increments in the K dimension

Diff for: Tensile/Component.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
2+
# Copyright 2020 Advanced Micro Devices, Inc. All rights reserved.
33
#
44
# Permission is hereby granted, free of charge, to any person obtaining a copy
55
# of this software and associated documentation files (the "Software"), to deal
@@ -72,7 +72,7 @@ def PartialMatch(pattern, obj):
7272
for key, value in pattern.items():
7373
if key not in obj:
7474
return False
75-
75+
7676
objValue = obj[key]
7777
if isinstance(value, collections.abc.Mapping) and \
7878
isinstance(objValue, collections.abc.Mapping):

Diff for: Tensile/Components/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
def use(): pass
33

4-
__all__ = ["MAC_F16"]
4+
__all__ = ["MAC_F16"]

Diff for: Tensile/KernelWriterAssembly.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6027,7 +6027,7 @@ def endSummation(self, kernel):
60276027
# lastVgprForReads ^ ^ ^
60286028
# startVgprReuse ^ ^
60296029
# lastValuC ^
6030-
# if valuC does not include all of lastVgprForReads, we can reuse the
6030+
# if valuC does not include all of lastVgprForReads, we can reuse the
60316031
# non-overlapped part of lastVgprForReads
60326032
# |<-------------- valuC -------------->|
60336033
# |xxxxxxxxxxxxxxxxxxxxx|xxxxxxxxxxxxxxx|oooooo|xx|
@@ -6036,7 +6036,7 @@ def endSummation(self, kernel):
60366036
# startVgprReuse ^
60376037
vbegin = self.numVgprValuC
60386038
vsize = max(0, self.lastVgprForReads-self.numVgprValuC)
6039-
else:
6039+
else:
60406040
vbegin = self.startVgprValuA
60416041
vsize = self.lastVgprForReads - self.startVgprValuA
60426042

0 commit comments

Comments
 (0)