Skip to content

Commit

Permalink
Merge commit '54ef11a83339b0d927b8302a22f81045172117d4' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
rosecompiler committed Oct 21, 2011
2 parents 06962bd + 54ef11a commit 3b086e0
Show file tree
Hide file tree
Showing 27 changed files with 914 additions and 386 deletions.
2 changes: 0 additions & 2 deletions projects/PolyhedralModel/src/rose-pragma/PolyhedricPragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ void generateAndReplace(Scheduling::PragmaSchedule & schedule) {
#endif

// Needed printers
/*
std::ostream & operator << (std::ostream & out, SgPragmaDeclaration & arg) {
out << "Polyhedric Pragma " << &arg;
return out;
}
*/

std::ostream & operator << (std::ostream & out, const SgPragmaDeclaration & arg) {
out << "Polyhedric Pragma " << &arg;
Expand Down
15 changes: 0 additions & 15 deletions projects/RTED/CppRuntimeSystem/CppRuntimeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#include "CppRuntimeSystem.h"

#ifdef ROSE_WITH_ROSEQT
#include "DebuggerQt/RtedDebug.h"
#endif

#include "rtedsync.h"


Expand Down Expand Up @@ -116,17 +112,6 @@ void RuntimeSystem::readConfigFile()
}


void RuntimeSystem::checkpoint(const SourcePosition& pos)
{
curPos = pos;

#ifdef ROSE_WITH_ROSEQT
if(qtDebugger)
RtedDebug::instance()->startGui();
#endif
}



// --------------------- Violations ---------------------------------

Expand Down
22 changes: 18 additions & 4 deletions projects/RTED/CppRuntimeSystem/CppRuntimeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "StackManager.h"
#include "PointerManager.h"

#ifdef ROSE_WITH_ROSEQT
#include "DebuggerQt/RtedDebug.h"
#endif


/**
* @brief Main API of the runtimesystem. Provides direct and indirect access to
Expand Down Expand Up @@ -98,11 +102,21 @@ struct RuntimeSystem
void violationHandler(RuntimeViolation & vio) throw (RuntimeViolation);


/// call this function to inform the runtimesystem what the current position in sourcecode is
/// this information is used for printing errors/warnings
void checkpoint(const SourcePosition & pos) ;
/// call this function to inform the runtimesystem what the current
/// position in sourcecode is. This information is used for printing
/// errors/warning
void checkpoint(const SourcePosition& pos)
{
curPos = pos;

#ifdef ROSE_WITH_ROSEQT
if(qtDebugger)
RtedDebug::instance()->startGui();
#endif
}


const SourcePosition & getCodePosition() const {return curPos; }
const SourcePosition& getCodePosition() const { return curPos; }

/// if testing mode is true exceptions are thrown when a violations occurs
/// otherwise abort is called, default false
Expand Down
10 changes: 4 additions & 6 deletions projects/RTED/CppRuntimeSystem/DebuggerQt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@
#include <QListWidgetItem>

#include "MainWindow.h"
#include "qcodeedit.h"

#include "RtedDebug.h"
#include "../CppRuntimeSystem.h"

#include "qcodeedit.h"

#include "ui_MainWindow.h"

#include "TypeInfoDisplay.h"
#include "MemoryTypeDisplay.h"
#include "VariablesTypeDisplay.h"
#include "PointerDisplay.h"

#include "ItemTreeModel.h"

#include "ModelRoles.h"


DbgMainWindow::DbgMainWindow(RtedDebug * dbgObj_,
QWidget * par)
DbgMainWindow::DbgMainWindow(RtedDebug * dbgObj_, QWidget * par)
: QMainWindow(par),
dbgObj(dbgObj_),
singleStep(true),
Expand Down
6 changes: 2 additions & 4 deletions projects/RTED/CppRuntimeSystem/DebuggerQt/RtedDebug.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "RtedDebug.h"

#include <QDebug>

#include <pthread.h>

#include "MainWindow.h"
#include "../CppRuntimeSystem.h"

RtedDebug * RtedDebug::single = NULL;

Expand Down
11 changes: 3 additions & 8 deletions projects/RTED/CppRuntimeSystem/DebuggerQt/RtedDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
#ifndef RTEDDEBUG_H
#define RTEDDEBUG_H

#include <pthread.h>

#include <QApplication>
#include <QObject>


#include "MainWindow.h"
#include "../CppRuntimeSystem.h"


#include <pthread.h>

#include <QDebug>

struct DbgMainWindow;

class RtedDebug
{
struct ThreadData
Expand Down
4 changes: 3 additions & 1 deletion projects/RTED/CppRuntimeSystem/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ include $(top_srcdir)/config/Makefile.for.ROSE.includes.and.libs
RuntimeSystemlibdir = $(libdir)
RuntimeSystemlib_LTLIBRARIES = libCppRuntimeSystem.la

AM_CXXFLAGS = -g -Wall -Wextra

if ROSE_WITH_UPC
AM_UPCFLAGS = -DWITH_UPC=1 -DIN_TARGET_LIBS
AM_UPCFLAGS = -g -Wall -Wextra -DWITH_UPC=1 -DIN_TARGET_LIBS
RuntimeSystemlib_LTLIBRARIES += libUpcRuntimeSystem.la
endif

Expand Down
11 changes: 10 additions & 1 deletion projects/RTED/CppRuntimeSystem/MemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace
typedef unsigned int CacheIdx;
typedef MemoryType::Location Location;

static const char CACHEELEMS = 4;
static const unsigned CACHEELEMS = 4;

CacheIdx pos;
MemoryType* cache[CACHEELEMS];
Expand Down Expand Up @@ -896,6 +896,15 @@ void MemoryManager::freeMemory(MemoryType* m, MemoryType::AllocKind freekind)

// successful free, erase allocation info from map
mem.erase(m->beginAddress());

if ( diagnostics::message(diagnostics::memory) )
{
std::stringstream msg;

msg << "++ deallocate: " << *m << std::endl;

RuntimeSystem::instance()->printMessage( msg.str() );
}
}


Expand Down
49 changes: 21 additions & 28 deletions projects/RTED/CppRuntimeSystem/RsType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,49 +71,42 @@ bool RsType::checkSubtypeRecursive(size_t offset, const RsType* type) const
//rs->printMessage(" >>> checkSubtypeRecursive ");
const RsType* result = this;
size_t size = type -> getByteSize();
size_t resultsize = result->getByteSize();

bool isunion = false;
unsigned int resultsize = result->getByteSize();
while(resultsize >= size) {
//rs->printMessage(" >> while result->getByteSize() >= size "+
// ToString(resultsize)+" : " +ToString(size));
//rs->printMessage(" >>> checking result == type : "+result->getName()+
// " "+type->getName());
if( result == type )
return true;
while (resultsize >= size)
{
if ( result == type ) return true;

// tps (09/10/09) Handle union type
const RsClassType* ct_result = dynamic_cast<const RsClassType*>( result);
if (ct_result && ct_result->isUnionType()) isunion=true;
const bool isunion = (ct_result && ct_result->isUnionType());

int subTypeId = -1;
std::vector<int> subTypeIdvec;
if (isunion==false)
subTypeId = result->getSubtypeIdAt(offset);
else
subTypeIdvec = ct_result->getSubtypeUnionIdAt(offset);
if (isunion)
{
std::vector<int> subTypeIdvec = ct_result->getSubtypeUnionIdAt(offset);

//rs->printMessage(" >> subTypeId: "+ToString(subTypeId)+" isunion:"+
// ToString(isunion));
if ( (isunion && subTypeIdvec.size()==0)
|| (!isunion && subTypeId == -1)
) {
// no refinement is possible
//rs->printMessage(" >>> subTypeId == -1 .");
return false;
}
if (subTypeIdvec.size() == 0) return false;

if (isunion) {
std::vector<int>::const_iterator it = subTypeIdvec.begin();
// iterate over the members and find the matching one
for (; it!=subTypeIdvec.end(); ++it) {
subTypeId = *it;
// addr_type temp_offset = offset- result->getSubtypeOffset(subTypeId);
const RsType* temp_result = result->getSubtype(subTypeId);

const RsType* temp_result = result->getSubtype(subTypeId);
if (temp_result==type)
break;
}
}
else
{
subTypeId = result->getSubtypeIdAt(offset);

if (subTypeId == -1) return false;
}

//rs->printMessage(" >> subTypeId: "+ToString(subTypeId)+" isunion:"+
// ToString(isunion));

// continue as before and get the subtype
offset -= result->getSubtypeOffset(subTypeId);
Expand All @@ -122,7 +115,7 @@ bool RsType::checkSubtypeRecursive(size_t offset, const RsType* type) const
result = result->getSubtype(subTypeId);
//rs->printMessage(" >> result = result->getSubtype(subTypeId) : "+
// result->getName()+"\n");
if (isunion==false)
if (!isunion)
resultsize = result->getByteSize();
}
//rs->printMessage(" >>> result: bytesize: " + ToString( result -> getByteSize())+
Expand Down
9 changes: 9 additions & 0 deletions projects/RTED/CppRuntimeSystem/StackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ void StackManager::beginScope(const std::string & name)
void StackManager::endScope(size_t scopecount)
{
const size_t noScopes = scope.size();

if (noScopes < scopecount)
{
std::stringstream out;

out << "#internal Error at: " << rtedRTS(this)->getCodePosition() << '\n';
RuntimeSystem::instance()->printMessage(out.str());
}

assert( noScopes >= scopecount );

const ScopeContainer::iterator limit = scope.end();
Expand Down
11 changes: 8 additions & 3 deletions projects/RTED/ParallelRTS.upc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// \hack see comment in CppRuntimeSystem/ptrops.upc
shared[1] char rted_base_hack[THREADS];

shared[1] int ctrInitVariables[THREADS];

// flag passed to the processing functions in the RuntimeSystem.cpp
// indicating that the origin is in another thread
static const int msgHandling = 0;
Expand Down Expand Up @@ -511,6 +513,8 @@ void snd_InitVariable( rted_TypeDesc td,
// other threads can only deref shared addresses;
if (!inSharedRegion(address) || (pointer_move && !inSharedRegion(heap_address))) return;

++ctrInitVariables[MYTHREAD];

// \note td.desc.shared_mask != 0 is NOT the same as testing whether an
// address is in the shared memory region.
// The shared mask test does not include C - pointers to the local
Expand Down Expand Up @@ -735,12 +739,13 @@ void rted_ProcessMsg()

void rted_PrintStats()
{
fprintf(stderr, "(#%i) sndInitVar = %i\n", MYTHREAD, ctrInitVariables[MYTHREAD]);
#ifdef NDEBUG
fprintf(stderr, "(#%i) *RELEASE MODE* \n", MYTHREAD);
#endif /* NDEBUF */

// fprintf(stderr, "(#%i) *RELEASE MODE* \n", MYTHREAD);
#else
fprintf(stderr, "(#%i) snd = %i rcv = %i\n", MYTHREAD, sndctr, rcvctr);
fflush(stderr);
#endif /* NDEBUF */
}

void rted_UpcAllInitialize()
Expand Down
31 changes: 18 additions & 13 deletions projects/RTED/RtedSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ static
void set_rtedenum(SgScopeStatement& n, const std::string& name, SgEnumDeclaration*& res)
{
res = n.lookup_enum_symbol(rtedIdentifier(name))->get_declaration();
ROSE_ASSERT(res);
presence_test(name, res);
}

static
void set_rtedfunc(SgGlobal& n, const std::string& name, SgFunctionSymbol*& res)
{
res = n.lookup_function_symbol(rtedIdentifier(name));
// cannot assert for upc functions :( was: ROSE_ASSERT(res);
presence_test(name, res);
}

void RtedSymbols::initialize(SgGlobal& n)
void RtedSymbols::initialize(SgGlobal& n, SourceFileType sft)
{
set_rtedfunc(n, "CreateArray", roseCreateArray);
set_rtedfunc(n, "AllocMem", roseAllocMem);
Expand All @@ -107,25 +107,30 @@ void RtedSymbols::initialize(SgGlobal& n)
set_rtedfunc(n, "ReallocateMemory", roseReallocateMemory);
set_rtedfunc(n, "CheckIfThisNULL", roseCheckIfThisNULL);
set_rtedfunc(n, "Addr", roseAddr);
set_rtedfunc(n, "AddrSh", roseAddrSh);
set_rtedfunc(n, "Close", roseClose);
set_rtedfunc(n, "UpcExitWorkzone", roseUpcExitWorkzone);
set_rtedfunc(n, "UpcEnterWorkzone", roseUpcEnterWorkzone);
set_rtedfunc(n, "UpcAllInitialize", roseUpcAllInitialize);
set_rtedfunc(n, "UpcBeginExclusive", roseUpcBeginExclusive);
set_rtedfunc(n, "UpcEndExclusive", roseUpcEndExclusive);

set_rtedfunc(n, "UpcEnterSharedPtr", roseUpcEnterSharedPtr);
set_rtedfunc(n, "UpcExitSharedPtr", roseUpcExitSharedPtr);
set_rtedfunc(n, "UpcAllInitialize", roseUpcAllInitialize);

set_rtedtype(n, "AddressDesc", roseAddressDesc);
set_rtedtype(n, "TypeDesc", roseTypeDesc);
set_rtedtype(n, "SourceInfo", roseSourceInfo);

set_rtedenum(n, "AllocKind", roseAllocKind);

set_typedef_type(n, "size_t", size_t_member);
// language specific symbols
if (sft == ftUPC)
{
set_rtedfunc(n, "UpcExitWorkzone", roseUpcExitWorkzone);
set_rtedfunc(n, "UpcEnterWorkzone", roseUpcEnterWorkzone);

set_rtedfunc(n, "UpcBeginExclusive", roseUpcBeginExclusive);
set_rtedfunc(n, "UpcEndExclusive", roseUpcEndExclusive);
set_rtedfunc(n, "UpcEnterSharedPtr", roseUpcEnterSharedPtr);
set_rtedfunc(n, "UpcExitSharedPtr", roseUpcExitSharedPtr);
set_rtedfunc(n, "AddrSh", roseAddrSh);
}

// other symbols
set_typedef_type(n, "size_t", size_t_member);
}

const std::string RtedSymbols::prefix("rted_");
12 changes: 11 additions & 1 deletion projects/RTED/RtedSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

#include "rose.h"

enum SourceFileType
{
ftUnknown = 0,
ftHeader = 1,
ftCbase = 2,
ftClang = 4 | ftCbase, // C
ftCxx = 8 | ftCbase, // C++
ftUPC = 16 | ftCbase // UPC
};

struct RtedSymbols
{
SgFunctionSymbol* roseCreateArray;
Expand Down Expand Up @@ -86,7 +96,7 @@ struct RtedSymbols
size_t_member(NULL)
{}

void initialize(SgGlobal& n);
void initialize(SgGlobal& n, SourceFileType sft);

static const std::string prefix;
};
Expand Down
Loading

0 comments on commit 3b086e0

Please sign in to comment.