From 12c8715e9ec99bcdfdd8a18401a4ae6292b0db79 Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 27 Sep 2010 21:37:49 +0000 Subject: [PATCH] no functional change - adding Print function for a couple of classes - minor code cleanup, including const'ness of functions - adding helper class for bookeeping of forwarded segments (for later use) --- HLT/BASE/AliHLTConsumerDescriptor.cxx | 13 +++ HLT/BASE/AliHLTConsumerDescriptor.h | 23 +++--- HLT/BASE/AliHLTDataBuffer.cxx | 79 ++++++++++++++++-- HLT/BASE/AliHLTDataBuffer.h | 94 +++++++++++++++++++-- HLT/BASE/AliHLTTask.cxx | 114 +++++++++++++++++++------- HLT/BASE/AliHLTTask.h | 5 ++ 6 files changed, 279 insertions(+), 49 deletions(-) diff --git a/HLT/BASE/AliHLTConsumerDescriptor.cxx b/HLT/BASE/AliHLTConsumerDescriptor.cxx index 0ae25ea319a..4fe97504202 100644 --- a/HLT/BASE/AliHLTConsumerDescriptor.cxx +++ b/HLT/BASE/AliHLTConsumerDescriptor.cxx @@ -112,3 +112,16 @@ int AliHLTConsumerDescriptor::ReleaseActiveDataSegment(AliHLTDataBuffer::AliHLTD } return iResult; } + +void AliHLTConsumerDescriptor::Print(const char* /*option*/) const +{ + // print info about this descriptor + cout << "AliHLTConsumerDescriptor " << this + << " component ID " << (fpConsumer?fpConsumer->GetComponentID():"NULL") + //<< " chain ID " << (fpConsumer?fpConsumer->GetChainId():"NULL") + << endl; + for (unsigned i=0; iGetInputDataTypes(dtlist); @@ -433,28 +435,28 @@ int AliHLTDataBuffer::IsEmpty() return iResult; } -int AliHLTDataBuffer::GetNofSegments() +int AliHLTDataBuffer::GetNofSegments() const { // see header file for function documentation int iResult=fSegments.size() + fForwardedSegments.size(); return iResult; } -int AliHLTDataBuffer::GetNofConsumers() +int AliHLTDataBuffer::GetNofConsumers() const { // see header file for function documentation int iResult=fConsumers.size() + GetNofActiveConsumers() + fReleasedConsumers.size(); return iResult; } -int AliHLTDataBuffer::GetNofPendingConsumers() +int AliHLTDataBuffer::GetNofPendingConsumers() const { // see header file for function documentation int iResult=fConsumers.size(); return iResult; } -int AliHLTDataBuffer::GetNofActiveConsumers() +int AliHLTDataBuffer::GetNofActiveConsumers() const { // see header file for function documentation int iResult=fActiveConsumers.size(); @@ -1027,7 +1029,7 @@ int AliHLTDataBuffer::AliHLTRawBuffer::Merge(const AliHLTDataBuffer::AliHLTRawBu return -EINVAL; } -void AliHLTDataBuffer::AliHLTRawBuffer::Print(const char* option) +void AliHLTDataBuffer::AliHLTRawBuffer::Print(const char* option) const { /// print buffer information if (strcmp(option, "min")!=0) { @@ -1361,3 +1363,70 @@ AliHLTDataBuffer::AliHLTRawPage* AliHLTDataBuffer::AliHLTRawPage::NextPage(const } return NULL; } + +void AliHLTDataBuffer::AliHLTDataSegment::Print(const char* /*option*/) const +{ + // print info for data segment + cout << "AliHLTDataSegment " << this + << " " << AliHLTComponent::DataType2Text(fDataType) + << " " << hex << fSpecification << dec + << " Ptr " << (void*)fPtr + << " offset " << fSegmentOffset + << " size " << fSegmentSize + << endl; +} + +void AliHLTDataBuffer::AliHLTForwardedDataSegment::Print(const char* option) const +{ + // print info for data segment + cout << "AliHLTForwardeDataSegment " << this << endl; + cout << " my : "; AliHLTDataSegment::Print(option); + cout << " parent: "; fParentSegment.Print(option); + cout << " task : "; + if (fParentTask) fParentTask->Print(""); + else cout << "nil" << endl; +} + +void AliHLTDataBuffer::Print(const char* option) const +{ + // print info for data buffer + unsigned i=0; + cout << "AliHLTDataBuffer " << this << endl; + cout << " raw buffer " << fpBuffer << endl; + if (fpBuffer) { + cout << " "; + fpBuffer->Print(option); + } + + cout << " total segments: " << GetNofSegments() << endl; + cout << " data segments: " << fSegments.size() << endl; + for (i=0; iPrint(option); + } + + cout << " active consumers: " << GetNofActiveConsumers() << endl; + for (i=0; iPrint(option); + } + + cout << " released consumers: " << fReleasedConsumers.size() << endl; + for (i=0; iPrint(option); + } + +} diff --git a/HLT/BASE/AliHLTDataBuffer.h b/HLT/BASE/AliHLTDataBuffer.h index e4fd8adfa6b..9a0871fdc35 100644 --- a/HLT/BASE/AliHLTDataBuffer.h +++ b/HLT/BASE/AliHLTDataBuffer.h @@ -181,27 +181,27 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * Get the number of segments including the forwarded data blocks. * @return number of segments */ - int GetNofSegments(); + int GetNofSegments() const; /** * Get the total number of consumers. * This gives the number of consumers regardless of their state. * @return number of consumers */ - int GetNofConsumers(); + int GetNofConsumers() const; /** * Get the number of consumers which still need to be processed during * the current event. * @return number of consumers */ - int GetNofPendingConsumers(); + int GetNofPendingConsumers() const; /** * Get the number of consumers currently under processing. * @return number of active consumers */ - int GetNofActiveConsumers(); + int GetNofActiveConsumers() const; /** * Check if a consumer is already in the list @@ -219,6 +219,11 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging */ int Reset(); + /** + * Print info about the buffer + */ + virtual void Print(const char* option) const; + /** * Set local logging level * logging filter for individual object @@ -286,6 +291,30 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging { } + AliHLTDataSegment(const AliHLTDataSegment& src) + : + fDataType(src.fDataType), + fPtr(src.fPtr), + fSegmentOffset(src.fSegmentOffset), + fSegmentSize(src.fSegmentSize), + fSpecification(src.fSpecification) + { + // AliHLTDataSegment just stores external pointers and properties + } + + AliHLTDataSegment& operator=(const AliHLTDataSegment& src) + { + // AliHLTDataSegment just stores external pointers and properties + fDataType=src.fDataType; + fPtr=src.fPtr; + fSegmentOffset=src.fSegmentOffset; + fSegmentSize=src.fSegmentSize; + fSpecification=src.fSpecification; + return *this; + } + + virtual ~AliHLTDataSegment() {} + AliHLTUInt8_t* GetPtr() const {return (AliHLTUInt8_t*)*this;} AliHLTUInt32_t GetSize() const {return fSegmentSize;} @@ -296,6 +325,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging } operator AliHLTUInt8_t*() const {return fPtr+fSegmentOffset;} + virtual void Print(const char* option) const; + private: /** the data type of this segment */ AliHLTComponentDataType fDataType; // see above @@ -310,6 +341,57 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging }; + /** + * @class AliHLTForwardedDataSegment + * @brief Descriptor of a forwarded data segment. + * Contains in addition information about the parent of this forwarded + * block and the original data type and specification + */ + class AliHLTForwardedDataSegment : public AliHLTDataSegment { + friend class AliHLTDataBuffer; // TODO: implement some getters/setters + public: + AliHLTForwardedDataSegment() + : AliHLTDataSegment() + , fParentSegment() + , fParentTask(NULL) + { + } + + AliHLTForwardedDataSegment(AliHLTDataSegment& mySegment, AliHLTDataSegment& parentSegment, AliHLTTask* parentTask) + : AliHLTDataSegment(mySegment) + , fParentSegment(parentSegment) + , fParentTask(parentTask) + { + } + + AliHLTForwardedDataSegment(const AliHLTForwardedDataSegment& src) + : AliHLTDataSegment(src), + fParentSegment(src.fParentSegment), + fParentTask(src.fParentTask) + { + // AliHLTForwardedDataSegment just stores external pointers and properties + } + + AliHLTForwardedDataSegment& operator=(const AliHLTForwardedDataSegment& src) + { + // AliHLTForwardedDataSegment just stores external pointers and properties + AliHLTDataSegment::operator=(src); + fParentSegment=src.fParentSegment; + fParentTask=src.fParentTask; + return *this; + } + + virtual ~AliHLTForwardedDataSegment() {} + + virtual void Print(const char* option) const; + + private: + /// description of the original segment + AliHLTDataSegment fParentSegment; // see above + /// the parent task + AliHLTTask* fParentTask; //!transient + }; + class AliHLTRawBuffer; typedef vector AliHLTRawBufferPList; @@ -355,7 +437,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging /** * Print page information */ - void Print(const char* option); + virtual void Print(const char* option); private: /** copy constructor prohibited */ @@ -457,7 +539,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging /** * Print buffer information */ - void Print(const char* option); + virtual void Print(const char* option) const; int operator==(void* ptr) const; int operator==(AliHLTUInt8_t* ptr) const {return fPtr==ptr;} diff --git a/HLT/BASE/AliHLTTask.cxx b/HLT/BASE/AliHLTTask.cxx index ad50928fa1c..2655213c254 100644 --- a/HLT/BASE/AliHLTTask.cxx +++ b/HLT/BASE/AliHLTTask.cxx @@ -1,26 +1,25 @@ // $Id$ -// splitted from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47 -/************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * * - * Primary Authors: Matthias Richter * - * for The ALICE HLT Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/** @file AliHLTTask.cxx - @author Matthias Richter - @date - @brief Implementation of HLT tasks. -*/ +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* for The ALICE HLT Project. * +//* * +//* Permission to use, copy, modify and distribute this software and its * +//* documentation strictly for non-commercial purposes is hereby granted * +//* without fee, provided that the above copyright notice appears in all * +//* copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//************************************************************************** + +/// @file AliHLTTask.cxx +/// @author Matthias Richter +/// @date +/// @brief Implementation of HLT tasks. +/// // see header file for class documentation // or @@ -43,6 +42,7 @@ using namespace std; #include "AliHLTComponent.h" #include "AliHLTComponentHandler.h" #include "TList.h" +#include "AliHLTErrorGuard.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTTask) @@ -615,6 +615,19 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt6 eventTypeBlock.fSpecification=eventType; fBlockDataArray.push_back(eventTypeBlock); + if (CheckFilter(kHLTLogDebug)) Print("proc"); + + AliHLTUInt32_t iblock=0; + // check input and output buffers for consistency + // to be enabled after fixing bug with DataBuffer and forwarded SOR/EOR + //for (iblock=0; iblock= pTgtBuffer+size) continue; + // if (pTgtBuffer >= (AliHLTUInt8_t*)fBlockDataArray[iblock].fPtr+fBlockDataArray[iblock].fSize) continue; + // HLTFatal("input and output buffer overlap for block descriptor %d (ptr %p size %d): output buffer %p %d", + // iblock, fBlockDataArray[iblock].fPtr, fBlockDataArray[iblock].fSize, + // pTgtBuffer, size); + //} + // process evtData.fBlockCnt=fBlockDataArray.size(); iResult=pComponent->ProcessEvent(evtData, &fBlockDataArray[0], trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd); @@ -650,6 +663,8 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt6 } // check for duplicates in the output + // this check applies for forwarded data blocks where + // the ptr is not inside the target buffer AliHLTUInt32_t checkblock=0; for (; checkblockGetName(), pSrcTask, fpDataBuffer); fpDataBuffer->Forward(subscribedTaskList[iblock], &fBlockDataArray[iblock]); subscribedTaskList[iblock]=NULL; // not to be released in the loop further down @@ -720,7 +744,7 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt6 subscribedTaskList[iEOR]=NULL; // not to be released in the loop further down } if (iECS>=0 && subscribedTaskList[iECS]!=NULL) { - HLTDebug("forward EOR event (%s) segment %d (source task %s %p) to data buffer %p", AliHLTComponent::DataType2Text(fBlockDataArray[iECS].fDataType).c_str(), iECS, pSrcTask->GetName(), pSrcTask, fpDataBuffer); + HLTDebug("forward ECS event (%s) segment %d (source task %s %p) to data buffer %p", AliHLTComponent::DataType2Text(fBlockDataArray[iECS].fDataType).c_str(), iECS, pSrcTask->GetName(), pSrcTask, fpDataBuffer); fpDataBuffer->Forward(subscribedTaskList[iECS], &fBlockDataArray[iECS]); subscribedTaskList[iECS]=NULL; // not to be released in the loop further down } @@ -732,6 +756,9 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt6 } while (iResult==-ENOSPC && iNofTrial++<1); } + fBlockDataArray.clear(); + if (CheckFilter(kHLTLogDebug)) Print("proc"); + // now release all buffers which we have subscribed to iSourceDataBlock=0; AliHLTTaskPList::iterator element; @@ -862,6 +889,37 @@ void AliHLTTask::PrintStatus() } } +void AliHLTTask::Print(const char* options) const +{ + // Overloaded from TObject + if (strcmp(options, "proc")==0) { + // print processing info + HLTMessage("**********************************************"); + HLTMessage("******* AliHLTTask Processing info ***********"); + HLTMessage(" component: %p %s", fpComponent, (fpComponent?fpComponent->GetComponentID():"")); + HLTMessage(" data buffer: %p", fpDataBuffer); + if (fpDataBuffer) fpDataBuffer->Print(""); + HLTMessage(" input block descriptors: %d", fBlockDataArray.size()); + for (unsigned i=0; iGetComponentID():"") + << endl; +} + + int AliHLTTask::CustomInit(AliHLTComponentHandler* /*pCH*/) { // default implementation nothing to do diff --git a/HLT/BASE/AliHLTTask.h b/HLT/BASE/AliHLTTask.h index 01a72dec49d..dc443addbde 100644 --- a/HLT/BASE/AliHLTTask.h +++ b/HLT/BASE/AliHLTTask.h @@ -257,6 +257,11 @@ class AliHLTTask : public TObject, public AliHLTLogging { */ void PrintStatus(); + /** + * Overloaded from TObject + */ + void Print(const char* options) const; + /** * Search task dependency list recursively to find a dependency. * @param id id of the task to search for -- 2.43.0