Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Debug vitis
Browse files Browse the repository at this point in the history
  • Loading branch information
xlz-jbleclere committed Feb 4, 2021
1 parent c45b7f8 commit fc9278d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
26 changes: 13 additions & 13 deletions source/drm_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ class DRM_LOCAL DrmManager::Impl {
Debug( "DRM Communication Self-Test 2 succeeded" );
}

bool isNodeLockedMode() const {
bool isConfigNodeLockedMode() const {
return mLicenseType == eLicenseType::NODE_LOCKED;
}

Expand Down Expand Up @@ -944,7 +944,7 @@ class DRM_LOCAL DrmManager::Impl {
runBistLevel2();

// Determine frequency detection method if metering/floating mode is active
if ( !isNodeLockedMode() ) {
if ( !isConfigInNodeLock() ) {
determineFrequencyDetectionMethod();
if ( mFreqDetectionMethod == 3 ) {
detectDrmFrequencyMethod3();
Expand All @@ -963,7 +963,7 @@ class DRM_LOCAL DrmManager::Impl {
loadDerivedProduct( mDerivedProductFromConf );

// If node-locked license is requested, create license request file
if ( isNodeLockedMode() ) {
if ( isConfigInNodeLock() ) {

// Check license directory exists
if ( !isDir( mNodeLockLicenseDirPath ) )
Expand Down Expand Up @@ -1068,7 +1068,7 @@ class DRM_LOCAL DrmManager::Impl {
if ( !mBoardType.empty() )
json_output["boardType"] = mBoardType;
json_output["mode"] = (uint8_t)mLicenseType;
if ( !isNodeLockedMode() )
if ( !isConfigInNodeLock() )
json_output["drm_frequency_init"] = mFrequencyInit;

// Fulfill with DRM section
Expand Down Expand Up @@ -1161,7 +1161,7 @@ class DRM_LOCAL DrmManager::Impl {
json_request["saasChallenge"] = saasChallenge;
json_request["meteringFile"] = std::accumulate( meteringFile.begin(), meteringFile.end(), std::string("") );
json_request["request"] = "open";
if ( !isNodeLockedMode() )
if ( !isConfigInNodeLock() )
json_request["drm_frequency"] = mFrequencyCurr;
json_request["mode"] = (uint8_t)mLicenseType;

Expand All @@ -1184,7 +1184,7 @@ class DRM_LOCAL DrmManager::Impl {
json_request["sessionId"] = meteringFile[0].substr( 0, 16 );
checkSessionIDFromDRM( json_request );

if ( !isNodeLockedMode() )
if ( !isConfigInNodeLock() )
json_request["drm_frequency"] = mFrequencyCurr;
json_request["meteringFile"] = std::accumulate( meteringFile.begin(), meteringFile.end(), std::string("") );
json_request["request"] = "running";
Expand All @@ -1206,7 +1206,7 @@ class DRM_LOCAL DrmManager::Impl {
json_request["sessionId"] = meteringFile[0].substr( 0, 16 );
checkSessionIDFromDRM( json_request );

if ( !isNodeLockedMode() )
if ( !isConfigInNodeLock() )
json_request["drm_frequency"] = mFrequencyCurr;
json_request["meteringFile"] = std::accumulate( meteringFile.begin(), meteringFile.end(), std::string("") );
json_request["request"] = "close";
Expand All @@ -1226,7 +1226,7 @@ class DRM_LOCAL DrmManager::Impl {
Debug( "Build health request #{}", mHealthCounter );
{
std::lock_guard<std::recursive_mutex> lock( mDrmControllerMutex );
if ( isNodeLockedMode() || isSessionRunning() ) {
if ( isConfigInNodeLock() || isSessionRunning() ) {
checkDRMCtlrRet( getDrmController().asynchronousExtractMeteringFile(
numberOfDetectedIps, saasChallenge, meteringFile ) );
} else {
Expand Down Expand Up @@ -1438,7 +1438,7 @@ class DRM_LOCAL DrmManager::Impl {
/// Extract license key and license timer from web service response
if ( mLicenseCounter == 0 )
licenseKey = JVgetRequired( dna_node, "key", Json::stringValue ).asString();
if ( !isNodeLockedMode() )
if ( !isConfigInNodeLock() )
licenseTimer = JVgetRequired( dna_node, "licenseTimer", Json::stringValue ).asString();
mLicenseDuration = JVgetRequired( metering_node, "timeoutSecond", Json::uintValue ).asUInt();
if ( mLicenseDuration == 0 )
Expand All @@ -1457,7 +1457,7 @@ class DRM_LOCAL DrmManager::Impl {
}

// Load license timer
if ( !isNodeLockedMode() ) {
if ( !isConfigInNodeLock() ) {
checkDRMCtlrRet( getDrmController().loadLicenseTimerInit( licenseTimer ) );
Debug( "Wrote license timer #{} of session ID {} for a duration of {} seconds",
mLicenseCounter, mSessionID, mLicenseDuration );
Expand Down Expand Up @@ -1498,7 +1498,7 @@ class DRM_LOCAL DrmManager::Impl {
bool is_metered = isDrmCtrlInMetering();
if ( is_nodelocked && is_metered )
Unreachable( "DRM Controller cannot be in both Node-Locked and Metering/Floating license modes. " ); //LCOV_EXCL_LINE
if ( !isNodeLockedMode() ) {
if ( !isConfigInNodeLock() ) {
if ( !is_metered )
Unreachable( "DRM Controller failed to switch to Metering license mode" ); //LCOV_EXCL_LINE
Debug( "DRM Controller is in Metering license mode" );
Expand Down Expand Up @@ -2263,7 +2263,7 @@ class DRM_LOCAL DrmManager::Impl {
TRY
Debug( "Calling 'activate' with 'resume_session_request'={}", resume_session_request );

if ( isNodeLockedMode() ) {
if ( isConfigInNodeLock() ) {
// Install the node-locked license
installNodelockedLicense();
return;
Expand Down Expand Up @@ -2310,7 +2310,7 @@ class DRM_LOCAL DrmManager::Impl {
TRY
Debug( "Calling 'deactivate' with 'pause_session_request'={}", pause_session_request );

if ( isNodeLockedMode() ) {
if ( isConfigInNodeLock() ) {
return;
}
if ( !isSessionRunning() ) {
Expand Down
1 change: 1 addition & 0 deletions tests/fpga_drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def _augment_exception(action):
try:
yield
except RuntimeError as exception:
print('Caugth exception:\n>', '\n> '.join(str(exception).strip().split('\n')))
exception.args = (
'Unable to %s FPGA: %s' % (action, exception.args[0].strip()),)
raise
Expand Down
46 changes: 23 additions & 23 deletions tests/fpga_drivers/_xilinx_xrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,32 @@ class FpgaDriver(_FpgaDriverBase):
_name = _match(r'_(.+)\.py', _basename(__file__)).group(1)
_reglock = _Lock()

def _get_driver(self):
@staticmethod
def get_xrt_lib():
"""
Detect XRT installation path:
"""
for prefix in (_environ.get("XILINX_XRT", "/opt/xilinx/xrt"),
'/usr', '/usr/local'):
if _isfile(_join(prefix, 'bin/xbutil')):
return prefix
raise RuntimeError('Unable to find Xilinx XRT')

@staticmethod
def _get_driver():
"""
Get FPGA driver
Returns:
ctypes.CDLL: FPGA driver.
"""
if _isfile(_join(self._xrt_prefix, "lib/libxrt_aws.so")):
print('Loading XRT for AWS target'
fpga_library = _cdll.LoadLibrary(_join(self._xrt_prefix, "lib/libxrt_aws.so"))
elif _isfile(_join(self._xrt_prefix, "lib/libxrt_core.so")):
print('Loading XRT for common target'
fpga_library = _cdll.LoadLibrary(_join(self._xrt_prefix, "lib/libxrt_core.so"))
xrt_path = get_xrt_lib()
if _isfile(_join(xrt_path, "lib/libxrt_aws.so")):
print('Loading XRT for AWS target')
fpga_library = _cdll.LoadLibrary(_join(xrt_path, "lib/libxrt_aws.so"))
elif _isfile(_join(xrt_path, "lib/libxrt_core.so")):
print('Loading XRT for common target')
fpga_library = _cdll.LoadLibrary(_join(xrt_path, "lib/libxrt_core.so"))
else:
raise RuntimeError('Unable to find Xilinx XRT Library')
return fpga_library
Expand All @@ -83,25 +96,12 @@ def create_lock():
return XrtLock(self)
return create_lock

@property
def _xrt_prefix(self):
"""
Detect XRT installation prefix:
Returns:
str: prefix path.
"""
for prefix in (_environ.get("XILINX_XRT", "/opt/xilinx/xrt"),
'/usr', '/usr/local'):
if _isfile(_join(prefix, 'bin/xbutil')):
return prefix
raise RuntimeError('Unable to find Xilinx XRT')

@property
def _xbutil(self):
_xbutil_path = _join(self._xrt_prefix, 'bin/awssak')
xrt_path = get_xrt_lib()
_xbutil_path = _join(xrt_path, 'bin/awssak')
if not _isfile(_xbutil_path):
_xbutil_path = _join(self._xrt_prefix, 'bin/xbutil')
_xbutil_path = _join(xrt_path, 'bin/xbutil')
if not _isfile(_xbutil_path):
raise RuntimeError('Unable to find Xilinx XRT Board Utility')
return _xbutil_path
Expand Down

0 comments on commit fc9278d

Please sign in to comment.