Skip to content

Commit b0f8c78

Browse files
franzlinehill
authored andcommitted
Add libCEED to the suite
Added for AMD platform and tested locally on gfx906.
1 parent 8810697 commit b0f8c78

File tree

6 files changed

+271
-3
lines changed

6 files changed

+271
-3
lines changed

cfg.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,10 @@
134134
"repo_url": "https://github.com/CEED/Laghos.git",
135135
"branch": None,
136136
"commit_id": "a7f6123d42847f6bdbdb614f5af876541f49cd16"
137-
}
137+
},
138+
"libCEED": {
139+
"repo_url": "https://github.com/CEED/libCEED.git",
140+
"branch": "main",
141+
"commit_id": "83ae4962eb1665164b53413c90f83e857c5b69b9"
142+
},
138143
}

src/hiptestsuite/applications/hpc_apps/libceed/__init__.py

Whitespace-only changes.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
2+
# Copyright (c) 2023 Intel Finland Oy. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
from hiptestsuite.TesterRepository import Tester, Test, TestData
23+
from hiptestsuite.Test import HIPTestData, TestResult, HIP_PLATFORM
24+
from typing import Union, List
25+
from hiptestsuite.test_classifier import TestClassifier
26+
from hiptestsuite.applications.hpc_apps.libceed.libceed_build_amd import BuildRunAmd
27+
from hiptestsuite.common.hip_get_packages import HipPackages
28+
from hiptestsuite.common.hip_shell import execshellcmd
29+
30+
import os
31+
import re
32+
33+
# Common class to clone, set up, build and run test
34+
class PrepareTest():
35+
def __init__(self, cwd):
36+
self.cwdAbs = cwd
37+
self.app_path = os.path.join(self.cwdAbs,\
38+
"src/hiptestsuite/applications/hpc_apps/libceed/libCEED")
39+
self.thistestpath = self.app_path
40+
self.prepareobj = None
41+
self.libceed_repo = "" # Default
42+
self.libceed_branch = ""
43+
self.libceed_commitId = ""
44+
45+
def set_libceed_repoinfo(self, test_data: HIPTestData):
46+
validrepconfig = True
47+
if test_data.repos["libCEED"].repo_url != None:
48+
self.libceed_repo = test_data.repos["libCEED"].repo_url
49+
else:
50+
print("invalid config: no repo")
51+
validrepconfig = False
52+
if test_data.repos["libCEED"].branch != None:
53+
self.libceed_branch = test_data.repos["libCEED"].branch
54+
if test_data.repos["libCEED"].commit_id != None:
55+
self.libceed_commitId = test_data.repos["libCEED"].commit_id
56+
return validrepconfig
57+
58+
def downloadtest(self, logFile, test_data: HIPTestData):
59+
return HipPackages().pull_repo(logFile, self.libceed_repo,\
60+
self.libceed_branch, self.libceed_commitId, "libCEED")
61+
62+
def buildtest(self, logFile, platform, cuda_target):
63+
if platform == HIP_PLATFORM.amd:
64+
self.prepareobj = BuildRunAmd(self.thistestpath, logFile)
65+
else:
66+
print("Invalid/Unsupported Platform")
67+
return False
68+
if not self.prepareobj:
69+
return False
70+
return self.prepareobj.buildtest()
71+
72+
def clean(self):
73+
if self.prepareobj != None:
74+
self.prepareobj.clean()
75+
76+
def runtest(self, testnum):
77+
if self.prepareobj != None:
78+
self.prepareobj.runtest(testnum)
79+
80+
def parse_result(self, testnum):
81+
if self.prepareobj != None:
82+
return self.prepareobj.parse_result(testnum)
83+
return False
84+
85+
class LIBCEED(TestClassifier):
86+
def __init__(self):
87+
TestClassifier.__init__(self)
88+
89+
def add_matched_with_names(self, matched_with_names: Union[None, dict] = None):
90+
TestClassifier.add_matched_with_names(self, {"libceed": matched_with_names})
91+
92+
class UNIT(TestClassifier):
93+
def __init__(self):
94+
LIBCEED.__init__(self)
95+
96+
def add_matched_with_names(self, matched_with_names: Union[None, dict] = None):
97+
LIBCEED.add_matched_with_names(self, {"libceed": matched_with_names})
98+
99+
class LIBCEED_UNIT_TEST(Tester, PrepareTest):
100+
def __init__(self):
101+
Tester.__init__(self)
102+
self.cwd = os.getcwd()
103+
PrepareTest.__init__(self, self.cwd)
104+
105+
def getTests(self) -> List[Test]:
106+
test = Test()
107+
test.test_name = self.__class__.__name__
108+
classifier = UNIT()
109+
classifier.add_matched_with_names()
110+
test.classifiers = [classifier]
111+
test.tester = self
112+
return [test]
113+
114+
def clean(self):
115+
PrepareTest.clean(self)
116+
117+
def test(self, test_data: HIPTestData):
118+
print("=============== libCEED UNIT test ===============")
119+
# Set repo info
120+
isrepocfgvalid = self.set_libceed_repoinfo(test_data)
121+
if not isrepocfgvalid:
122+
test_data.test_result = TestResult.ERROR
123+
return
124+
125+
# Create the log directory
126+
resultLogDir = test_data.log_location
127+
with open(resultLogDir + "/libceed_unit.log", 'w+') as testLogger:
128+
res = self.downloadtest(testLogger, test_data)
129+
test_data.test_result = TestResult.FAIL
130+
if not res:
131+
return
132+
res = self.buildtest(testLogger, test_data.HIP_PLATFORM, test_data.build_for_cuda_target)
133+
if not res:
134+
return
135+
self.runtest(1)
136+
# Parse the test result
137+
if self.parse_result(1):
138+
test_data.test_result = TestResult.PASS
139+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
2+
# Copyright (c) 2023 Intel Finland Oy. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
import os
23+
import re
24+
import tempfile
25+
from hiptestsuite.common.hip_shell import *
26+
from hiptestsuite.applications.hpc_apps.libceed.libceed_parser_common import LibceedParser
27+
28+
class BuildRunAmd():
29+
def __init__(self, thistestpath, logFile):
30+
self.thistestpath = thistestpath
31+
self.logFile = logFile
32+
self.runlog = None
33+
self.rocm_path = os.environ.get('ROCM_PATH')
34+
if not self.rocm_path:
35+
self.rocm_path = "/opt/rocm"
36+
37+
def configure_build_libceed(self):
38+
path_check = os.path.join(self.thistestpath, "lib/libceed.so")
39+
if os.path.exists(path_check):
40+
print("libceed already built at ", path_check)
41+
return True
42+
make_variables = "FORTRAN=0 "
43+
44+
make_variables += " ROCM_DIR=" + self.rocm_path
45+
46+
print("libceed build in progress ..")
47+
cmd = "cd " + self.thistestpath + " && "
48+
cmd += ("make configure " + make_variables
49+
+ " OPT='-O2 -march=native' && make")
50+
runlogdump = tempfile.TemporaryFile("w+")
51+
print("building using command: ", cmd)
52+
execshellcmd_largedump(cmd, self.logFile, runlogdump, None)
53+
runlogdump.close()
54+
if not os.path.exists(path_check):
55+
print("libceed Build Failed, not found at: ", path_check)
56+
return False
57+
return True
58+
59+
def buildtest(self):
60+
if not self.configure_build_libceed():
61+
print("libceed configuration and build failed ..")
62+
return False
63+
return True
64+
65+
def runtest(self, testnum):
66+
print("Running libCEED Test" + str(testnum))
67+
cmd = "cd " + self.thistestpath + " && "
68+
cmd += "make BACKENDS=/gpu/hip/shared search=t3 exclude=t319 test"
69+
env = os.environ.copy()
70+
env['LD_LIBRARY_PATH'] = (self.rocm_path + '/lib:'
71+
+ env['LD_LIBRARY_PATH'])
72+
self.runlog = tempfile.TemporaryFile("w+")
73+
execshellcmd_largedump(cmd, self.logFile, self.runlog, env)
74+
75+
def clean(self):
76+
print("Cleaning libceed..")
77+
if self.runlog != None:
78+
self.runlog.close()
79+
80+
def parse_result(self, testnum):
81+
return LibceedParser(self.runlog).parse(testnum)
82+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
2+
# Copyright (c) 2023 Intel Finland Oy. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
import re
23+
24+
class LibceedParser():
25+
def __init__(self, results):
26+
results.seek(0)
27+
logbytes = results.read()
28+
self.results = logbytes
29+
30+
def parse(self, testnum):
31+
passcount = self.results.count("PASS")
32+
failcount = self.results.count("FAIL:")
33+
return passcount >= 32 and failcount == 0

src/hiptestsuite/common/hip_get_packages.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def __init__(self):
6363
self.mfemapppath = os.path.join(self.mfemrootpath, "mfem/")
6464
self.laghosrootpath = os.path.join(self.cwdAbs, "src/hiptestsuite/applications/hpc_apps/laghos/")
6565
self.laghosapppath = os.path.join(self.laghosrootpath, "Laghos/")
66+
# libCEED
67+
self.libceedrootpath = os.path.join(self.cwdAbs, "src/hiptestsuite/applications/hpc_apps/libceed/")
68+
self.libceedapppath = os.path.join(self.libceedrootpath, "libCEED/")
69+
6670

6771
def pull_repo(self, logFile, repo, branch, commitId, reponame):
6872
repo_root_path = ""
@@ -132,6 +136,13 @@ def pull_repo(self, logFile, repo, branch, commitId, reponame):
132136
repo_root_path = self.laghosapppath
133137
repo_location = self.laghosrootpath
134138
repo_dir = "Laghos"
139+
elif reponame == "libCEED":
140+
repo_root_path = self.libceedapppath
141+
repo_location = self.libceedrootpath
142+
repo_dir = "libCEED"
143+
else:
144+
print("repository: " + reponame + " does not exist in hip_get_packages.py")
145+
return False
135146

136147
if os.path.isdir(repo_root_path) and os.path.isdir(repo_root_path + "/.git"):
137148
print(reponame + " already exist")
@@ -149,8 +160,6 @@ def pull_repo(self, logFile, repo, branch, commitId, reponame):
149160
((commitId == "") or (commitId in currentcommitid)):
150161
print("This repo is up to date with config")
151162
return True
152-
else:
153-
print(reponame + " does not exist")
154163

155164
# Update the repo
156165
print("Updating: " + reponame)

0 commit comments

Comments
 (0)