-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Pluggable Validation Layer Checkers (#155)
* Support for Pluggable Validation Layer Checkers Signed-off-by: Neil R. Spruit <[email protected]>
- Loading branch information
Showing
44 changed files
with
7,001 additions
and
3,919 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
Copyright (C) 2024 Intel Corporation | ||
SPDX-License-Identifier: MIT | ||
""" | ||
import os | ||
import re | ||
import util | ||
import argparse | ||
|
||
templates_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates/checker/") | ||
|
||
""" | ||
generates checker files from the templates | ||
""" | ||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("name", type=str, help="Name of your Validation Layer checker in the form of 'CheckerName'.") | ||
parser.add_argument("out_dir", type=str, help="Root of the loader repository.") | ||
args = parser.parse_args() | ||
name = args.name | ||
env_name = name.upper() | ||
srcpath = os.path.join(args.out_dir, "source/layers/validation/checkers/") | ||
srcpath = os.path.join(srcpath, name) | ||
if not os.path.exists(srcpath): | ||
os.makedirs(srcpath) | ||
print("Generating Checker Template for %s\n" %(name)) | ||
loc = 0 | ||
template = "template.h.mako" | ||
fin = os.path.join(templates_dir, template) | ||
|
||
filename = "zel_%s_checker.h"%(name) | ||
fout = os.path.join(srcpath, filename) | ||
|
||
print("Generating %s..."%fout) | ||
loc += util.makoWrite( | ||
fin, fout, | ||
name=name) | ||
|
||
template = "template.cpp.mako" | ||
fin = os.path.join(templates_dir, template) | ||
|
||
filename = "zel_%s_checker.cpp"%(name) | ||
fout = os.path.join(srcpath, filename) | ||
|
||
print("Generating %s..."%fout) | ||
loc += util.makoWrite( | ||
fin, fout, | ||
name=name, | ||
env_name=env_name) | ||
|
||
template = "template.cmake.mako" | ||
fin = os.path.join(templates_dir, template) | ||
|
||
filename = "CMakeLists.txt" | ||
fout = os.path.join(srcpath, filename) | ||
|
||
print("Generating %s..."%fout) | ||
loc += util.makoWrite( | ||
fin, fout, | ||
name=name, | ||
TARGET_NAME="${TARGET_NAME}", | ||
CMAKE_CURRENT_LIST_DIR="${CMAKE_CURRENT_LIST_DIR}") |
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
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,5 @@ | ||
target_sources(${TARGET_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_LIST_DIR}/zel_${name}_checker.h | ||
${CMAKE_CURRENT_LIST_DIR}/zel_${name}_checker.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,35 @@ | ||
/* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* @file zel_${name}_checker.cpp | ||
* | ||
*/ | ||
#include "zel_${name}_checker.h" | ||
|
||
namespace validation_layer | ||
{ | ||
class ${name}Checker ${name}_checker; | ||
|
||
${name}Checker::${name}Checker() { | ||
enable${name} = getenv_tobool( "ZEL_ENABLE_${env_name}_CHECKER" ); | ||
if(enable${name}) { | ||
${name}Checker::ZE${name}Checker *zeChecker = new ${name}Checker::ZE${name}Checker; | ||
${name}Checker::ZES${name}Checker *zesChecker = new ${name}Checker::ZES${name}Checker; | ||
${name}Checker::ZET${name}Checker *zetChecker = new ${name}Checker::ZET${name}Checker; | ||
${name}_checker.zeValidation = zeChecker; | ||
${name}_checker.zetValidation = zetChecker; | ||
${name}_checker.zesValidation = zesChecker; | ||
validation_layer::context.validationHandlers.push_back(&${name}_checker); | ||
} | ||
} | ||
|
||
${name}Checker::~${name}Checker() { | ||
if(enable${name}) { | ||
delete ${name}_checker.zeValidation; | ||
delete ${name}_checker.zetValidation; | ||
delete ${name}_checker.zesValidation; | ||
} | ||
} | ||
} |
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,30 @@ | ||
/* | ||
* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* @file zel_${name}_checker.h | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include "ze_api.h" | ||
#include "ze_validation_layer.h" | ||
|
||
namespace validation_layer | ||
{ | ||
class __zedlllocal ${name}Checker : public validationChecker{ | ||
public: | ||
${name}Checker(); | ||
~${name}Checker(); | ||
|
||
class ZE${name}Checker : public ZEValidationEntryPoints {}; | ||
class ZES${name}Checker : public ZESValidationEntryPoints {}; | ||
class ZET${name}Checker : public ZETValidationEntryPoints {}; | ||
bool enable${name} = false; | ||
}; | ||
extern class ${name}Checker ${name}_checker; | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.