Exemplo n.º 1
0
uint32_t
TDNFRunTransaction(
    PTDNFRPMTS pTS,
    PTDNF pTdnf
    )
{
    uint32_t dwError = 0;

    dwError = rpmtsOrder(pTS->pTS);
    BAIL_ON_TDNF_ERROR(dwError);

    dwError = doCheck(pTS);
    BAIL_ON_TDNF_ERROR(dwError);

    rpmtsClean(pTS->pTS);

    fprintf(stdout, "Testing transaction\n");

    rpmtsSetFlags(pTS->pTS, RPMTRANS_FLAG_TEST);
    dwError = rpmtsRun(pTS->pTS, NULL, pTS->nProbFilterFlags);
    BAIL_ON_TDNF_ERROR(dwError);

    fprintf(stdout, "Running transaction\n");
    rpmtsSetFlags(pTS->pTS, RPMTRANS_FLAG_NONE);
    dwError = rpmtsRun(pTS->pTS, NULL, pTS->nProbFilterFlags);
    BAIL_ON_TDNF_ERROR(dwError);

cleanup:
    return dwError;

error:
    doCheck(pTS);
    goto cleanup;
}
Exemplo n.º 2
0
void GameScene::onTouchEnded(Touch* touch, Event* event)
{
    Point pos = touch->getLocation();
    SimpleGestures rtn = recognizer->endPoint(pos);
    switch (rtn) {
        case SimpleGesturesLeft:
            doLeft();
            doCheck();
            setScore(score);
            break;
        case SimpleGesturesRight:
            doRight();
            doCheck();
            setScore(score);
            break;
        case SimpleGesturesUp:
            doUp();
            doCheck();
            setScore(score);
            break; 
        case SimpleGesturesDown:
            doDown();
            doCheck();
            setScore(score);
            break;
        case SimpleGesturesNotSupport:
        case SimpleGesturesError:
            log("not support or error touch,use geometricRecognizer!!");
            break;
        default:
            break; 
    } 
} 
Exemplo n.º 3
0
  bool CountryInfoGetter::IsBelongToRegion(m2::PointD const & pt, IDSet const & regions) const
  {
    GetByPoint doCheck(*this, pt);
    for (size_t i = 0; i < regions.size(); ++i)
      if (m_countries[regions[i]].m_rect.IsPointInside(pt) && !doCheck(regions[i]))
        return true;

    return false;
  }
//------------------------------------------------------------------------------
// Name: createMenu
// Desc:
//------------------------------------------------------------------------------
QMenu *QGmailNotifier::createMenu() {
	QMenu *const menu = new QMenu(this);
	QAction *const view		= menu->addAction(tr("View Inbox"), this, SLOT(doView()));
	menu->addAction(tr("Compose a Message"), this, SLOT(doCompose()));
	menu->addAction(tr("Check Mail Now"), this, SLOT(doCheck()));
	menu->addAction(tr("Tell me Again..."), this, SLOT(doTell()));
	menu->addAction(tr("Options"), this, SLOT(doOptions()));
	menu->addAction(tr("About"), this, SLOT(doAbout()));

	if(currentMails_.size() != 0) {

		menu->addSeparator();
		QMenu *const convsations = menu->addMenu(tr("Unread Conversations"));

		QSettings settings;

		const int maxCons = settings.value("max_conversations", 10).value<int>();

		int index = 0;
		Q_FOREACH(GMailEntry entry, currentMails_) {
			QAction *const action = convsations->addAction(entry.author_name + " : " + entry.title, this, SLOT(readConversation()));
			action->setData(index++);
			if(index >= maxCons) {
				break;
			}
		}
//------------------------------------------------------------------------------
// Name: QGmailNotifier
// Desc:
//------------------------------------------------------------------------------
QGmailNotifier::QGmailNotifier(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), trayIcon_(0), alertIndex_(-1), animationIndex_(0) {

	ui.setupUi(this);

	gmailFeed_ = new GMailFeed(this);
	connect(gmailFeed_, SIGNAL(fetchComplete(QNetworkReply *)), this, SLOT(fetchComplete(QNetworkReply *)));

	trayIcon_ = new QSystemTrayIcon(this);
	trayIcon_->setContextMenu(createMenu());
	trayIcon_->setIcon(QIcon(":/img/normal.svgz"));

	connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(activated(QSystemTrayIcon::ActivationReason)));
	connect(trayIcon_, SIGNAL(messageClicked()), this, SLOT(messageClicked()));

	trayIcon_->show();

	// start the check timer
	timer_ = new QTimer(this);
	connect(timer_, SIGNAL(timeout()), this, SLOT(doCheck()));
	timer_->start(0);

	// setup the anim timer
	animationTimer_ = new QTimer(this);
	connect(animationTimer_, SIGNAL(timeout()), this, SLOT(doAnim()));
}
Exemplo n.º 6
0
void GameScene::onTouchEnded(Touch* touch, Event* event)
{
	//得到触摸结束时坐标
	Point endTouch = touch->getLocation();  //获取OpenGL坐标,以左下角为原点
	//计算手指在X,Y移动的距离
	endX = beginX - endTouch.x;
	endY = beginY - endTouch.y;
	if (abs(endX) > abs(endY))
	{
		//如果X轴移动的距离大于Y轴,则是左右移动
		if (endX + 5 > 0)
		{
			//向左移动
			doLeft();
			createCardNumber();
			doCheck();
			setScore(score);
		}
		else
		{
			//向右移动
			doRight();
			createCardNumber();
			doCheck();
			setScore(score);
		}
	}
	else //否则是上下移动
	{
		if (endY + 5 > 0)
		{
			//向下移动
			doDown();
			createCardNumber();
			doCheck();
			setScore(score);
		}
		else
		{
			//向上移动
			doUp();
			createCardNumber();
			doCheck();
			setScore(score);
		}
	}
}
Exemplo n.º 7
0
 int doCheck(TreeNode *node){
     if (!node){
         return 0;
     }
     int left = doCheck(node->left);
     if (left < 0){
         return -1;
     }
     int right = doCheck(node->right);
     if (right < 0){
         return -1;
     } else if (abs(left - right) > 1){
         return -1;
     }else {
         return max(left, right) + 1;
     }
 }
Exemplo n.º 8
0
	bool fixProblem(unsigned index, unsigned fix_type, MapEditor* editor)
	{
		if (index >= lines.size())
			return false;

		MapLine* line = map->getLine(lines[index]);
		if (line->s2())
		{
			// Flip
			if (fix_type == 0)
			{
				line->flip();
				return true;
			}

			// Create sector
			else if (fix_type == 1)
			{
				fpoint2_t pos = line->dirTabPoint(0.1);
				editor->createSector(pos.x, pos.y);
				doCheck();
				return true;
			}
		}
		else
		{
			// Delete
			if (fix_type == 0)
			{
				map->removeLine(line);
				doCheck();
				return true;
			}

			// Create sector
			else if (fix_type == 1)
			{
				fpoint2_t pos = line->dirTabPoint(0.1);
				editor->createSector(pos.x, pos.y);
				doCheck();
				return true;
			}
		}

		return false;
	}
Exemplo n.º 9
0
bool vfs::Path::expandEnv()
{
	vfs::String::ptr_t raw_ptr = &_path[0];
	std::stack<t_env> pos;
	vfs::Int32 pos_start = -1, pos_end = -1, pos_current = 0;
	while(*raw_ptr != 0)
	{
		if(*raw_ptr == L'$')
		{
			pos_start = pos_current;
		}
		else if(pos_start >= 0)
		{
			if(*raw_ptr == '(' && pos_current == (pos_start+1))
			{
				// ensure the syntax $(VARNAME) is followed
				pos_end = pos_start;
			}
			//else
			//{
			//	pos_start = pos_end = -1;
			//}
			else if(pos_start == pos_end && *raw_ptr == ')')
			{
				pos_end = pos_current;
			}
			//
			if(pos_end >= 0 && pos_start != pos_end)
			{
				t_env e;
				e.start = pos_start;
				e.end = pos_end;
				pos.push(e);
				pos_start = pos_end = -1;
			}
		}
		pos_current++;
		raw_ptr++;
	}
	if(!pos.empty())
	{
		while(!pos.empty())
		{
			t_env v = pos.top();
			vfs::String var_name = _path.substr(v.start+2, v.end-v.start-2);
			vfs::String var_value;
			if(!vfs::OS::getEnv(var_name, var_value))
			{
				VFS_LOG_WARNING(_BS(L"Could not expand environment variable : ") << var_name << _BS::wget);
				return false;
			}
			_path.replace(v.start,v.end-v.start+1,var_value.c_wcs());
			pos.pop();
		}
		doCheck();
	}
	return true;
}
void HighlightingItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                                     const QModelIndex &index) const
{
    static const int iconSize = 16;

    painter->save();

    const QStyleOptionViewItem opt = setOptions(index, option);
    painter->setFont(opt.font);

    QItemDelegate::drawBackground(painter, opt, index);

    // ---- do the layout
    QRect checkRect;
    QRect pixmapRect;
    QRect textRect;

    // check mark
    const bool checkable = (index.model()->flags(index) & Qt::ItemIsUserCheckable);
    Qt::CheckState checkState = Qt::Unchecked;
    if (checkable) {
        QVariant checkStateData = index.data(Qt::CheckStateRole);
        checkState = static_cast<Qt::CheckState>(checkStateData.toInt());
        checkRect = doCheck(opt, opt.rect, checkStateData);
    }

    // icon
    const QIcon icon = index.model()->data(index, Qt::DecorationRole).value<QIcon>();
    if (!icon.isNull()) {
        const QSize size = icon.actualSize(QSize(iconSize, iconSize));
        pixmapRect = QRect(0, 0, size.width(), size.height());
    }

    // text
    textRect = opt.rect.adjusted(0, 0, checkRect.width() + pixmapRect.width(), 0);

    // do layout
    doLayout(opt, &checkRect, &pixmapRect, &textRect, false);
    // ---- draw the items
    // icon
    if (!icon.isNull())
        icon.paint(painter, pixmapRect, option.decorationAlignment);

    // line numbers
    const int lineNumberAreaWidth = drawLineNumber(painter, opt, textRect, index);
    textRect.adjust(lineNumberAreaWidth, 0, 0, 0);

    // text and focus/selection
    drawText(painter, opt, textRect, index);
    QItemDelegate::drawFocus(painter, opt, opt.rect);

    // check mark
    if (checkable)
        QItemDelegate::drawCheck(painter, opt, checkRect, checkState);

    painter->restore();
}
Exemplo n.º 11
0
void FoldInitTypeCheck::check(const MatchFinder::MatchResult &Result) {
  // Given the iterator and init value type retreived by the matchers,
  // we check that the ::value_type of the iterator is compatible with
  // the init value type.
  const auto *InitType = Result.Nodes.getNodeAs<BuiltinType>("InitType");
  const auto *IterValueType =
      Result.Nodes.getNodeAs<BuiltinType>("IterValueType");
  assert(InitType != nullptr);
  assert(IterValueType != nullptr);

  const auto *CallNode = Result.Nodes.getNodeAs<CallExpr>("Call");
  assert(CallNode != nullptr);

  doCheck(*IterValueType, *InitType, *Result.Context, *CallNode);

  if (const auto *Iter2ValueType =
          Result.Nodes.getNodeAs<BuiltinType>("Iter2ValueType"))
    doCheck(*Iter2ValueType, *InitType, *Result.Context, *CallNode);
}
Exemplo n.º 12
0
bool Operation_Calculation::doCalculation(const DataStore &left, const DataStore &right, DataStore &answer) const
{
    bool b = doCheck(left, right);
    if (b)
    {
        answer = doInternalCalculation(left, right);
        return true;
    }
    throw std::exception();
}
Exemplo n.º 13
0
checkBook::checkBook(QDialog *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
	ui.setupUi(this);
	model = new QSqlTableModel;
	model->setTable("book_record");
	ui.bookTimeDateEdit->setMinimumDate(QDate::currentDate());
	ui.bookTimeDateEdit->setDate(QDate::currentDate());
	QObject::connect(ui.okPushButton, SIGNAL(clicked()), this, SLOT(doCheck()));
}
Exemplo n.º 14
0
QRect TasksViewDelegate::checkBoxRect(const QStyleOptionViewItem &option,
                                      const QVariant &variant) const
{
    const QRect bounding = option.rect; // TODO adjust if recording

    const QRect cbRect = doCheck(option, bounding, variant);

    // Position checkbox on the right, and vertically aligned
    return QStyle::alignedRect(option.direction, Qt::AlignRight | Qt::AlignVCenter,
                               cbRect.size(), bounding);
}
Exemplo n.º 15
0
        void RunBase()
        {
            for (size_t i = 0; i < m_Countries.size(); ++i)
            {
                PointChecker doCheck(m_Countries[i]->m_regions);
                m_fb.ForEachGeometryPoint(doCheck);

                if (doCheck.m_belongs)
                    m_pPolygonizer->EmitFeature(m_Countries[i], m_fb);
            }
        }
Exemplo n.º 16
0
void CheckboxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    bool value = index.data(Qt::EditRole).toBool();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QSize size = check(option, option.rect, Qt::Checked).size();
#else
    QSize size = doCheck(option, option.rect, Qt::Checked).size();
#endif

    QRect checkboxRect = QStyle::alignedRect(option.direction, Qt::AlignCenter, size, option.rect);
    drawCheck(painter, option, checkboxRect, (value ? Qt::Checked : Qt::Unchecked));
}
Exemplo n.º 17
0
vfs::Path::Path(std::string const& sPath)
{
	if(vfs::Settings::getUseUnicode())
	{
		vfs::String::as_utf16(sPath,_path); 
	}
	else
	{
		vfs::String::widen(sPath,_path);
	}
	doCheck();
}
Exemplo n.º 18
0
Idle::Idle(QObject *parent)
  : QObject(parent)
  , m_platform(0)
  , m_idleTime(0)
{
  // try to use platform idle
  m_platform = new IdlePlatform();
  if (!m_platform->init()) {
    delete m_platform;
    m_platform = 0;
  }

  connect(&m_timer, SIGNAL(timeout()), SLOT(doCheck()));
}
Exemplo n.º 19
0
void QItemDelegate::updateEditorGeometry(QWidget *editor,
                                         const QStyleOptionViewItem &option,
                                         const QModelIndex &index) const
{
    if (!editor)
        return;
    Q_ASSERT(index.isValid());
    QPixmap pixmap = decoration(option, index.data(Qt::DecorationRole));
    QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString());
    QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());
    QRect textRect = textRectangle(0, option.rect, option.font, text);
    QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole));
    QStyleOptionViewItem opt = option;
    opt.showDecorationSelected = true; // let the editor take up all available space
    doLayout(opt, &checkRect, &pixmapRect, &textRect, false);
    editor->setGeometry(textRect);
}
Exemplo n.º 20
0
  void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & option,
    const QModelIndex & index ) const {
	  //if (index.column() == 0) return;
    QStyleOptionViewItemV3 opt = setOptions(index, option);
 
    // prepare
    painter->save();

    // get the data and the rectangles
    const QPixmap& pixmap
      = qvariant_cast<QPixmap>(index.data(Qt::DecorationRole));
    QRect decorationRect = QRect(opt.rect.topLeft(), pixmap.size());
    decorationRect.moveTo(decorationRect.left(), decorationRect.top() + 10);
    const QString& text = index.data(Qt::DisplayRole).toString();
    QFontMetrics fm(painter->font());
    QRect displayRect = QRect(decorationRect.bottomLeft(),
      QSize(fm.width(text),fm.height()));

    QRect checkRect;
    Qt::CheckState checkState = Qt::Unchecked;
    QVariant value = index.data(Qt::CheckStateRole);

    if (value.isValid()) {
      checkState = static_cast<Qt::CheckState>(value.toInt());
#if QT_VERSION >= 0x050000
      checkRect = doCheck(opt, opt.rect, value);
#else
      checkRect = check(opt, opt.rect, value);
#endif
    }

    // do the layout

    //  doLayout(opt, &checkRect, &decorationRect, &displayRect, false);

    // draw the item

    drawBackground(painter, opt, index);
    painter->drawPixmap(decorationRect, pixmap);
    painter->drawText(displayRect, text);

    drawFocus(painter, opt, displayRect);

    // done
    painter->restore();
  }
Exemplo n.º 21
0
Idle::Idle()
{
	d = new Private;
	d->active = false;
	d->idleTime = 0;

	// try to use platform idle
	if(!platform) {
		IdlePlatform *p = new IdlePlatform;
		if(p->init())
			platform = p;
		else
			delete p;
	}
	if(platform)
		++platform_ref;

	connect(&d->checkTimer, SIGNAL(timeout()), SLOT(doCheck()));
}
Exemplo n.º 22
0
void UpdateDialog::setState(UpdaterState newState)
{
    ui->progressBar->setValue(0);
    state = newState;

    switch (state)
    {
    case CanCheck:
        resetUpdateData();
        ui->updateButton->setText( tr("Check for updates") );
        setInteractable(true);

        break;

    case Checking:
        setInteractable(false);
        doCheck();
        break;

    case CanUpdate:
        ui->updateButton->setText( tr("Update client") );
        setInteractable(true);
        break;

    case Updating:
        setInteractable(false);
        doUpdate();
        break;

    case CanClose:
        ui->updateButton->setText( tr("Close updater") );
        setInteractable(true);
        break;

    default:
        log( tr("Error! Updater tool swithed to unknown state!") );
        break;
    }
}
Exemplo n.º 23
0
void GameScene::onTouchEnded(Touch* touch, Event* event) {
    if (isWin() || isGameOver()) {
        return;
    }

    GestureDetector::GestureType gesture = mGestureDetector.endPoint(touch->getLocation());
    bool gestureValid = true;
    bool moved = false;
    switch (gesture) {
    case GestureDetector::MoveLeft:
        moved = moveLeft();
        break;
    case GestureDetector::MoveRight:
        moved = moveRight();
        break;
    case GestureDetector::MoveUp:
        moved = moveUp();
        break;
    case GestureDetector::MoveDown:
        moved = moveDown();
        break;
    case GestureDetector::Unknown:
    default:
        gestureValid = false;
        break;
    }

    if (gestureValid) {
        if (moved) {
            generateCard(true);
            CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(
                    MOVE_SUCESS_SOUND, false);
        } else {
            CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(
                    MOVE_FAILED_SOUND, false);
        }
        doCheck();
    }
}
void paraNode()
/* paraNode - a net server. */
{
char *line;
char *command;
struct sockaddr_in sai;

/* We have to know who we are... */
hostName = getMachine();
initRandom();
getTicksToHundreths();

/* log init */
if (optionExists("log"))
    logOpenFile("paraNode", optionVal("log", NULL));
else    
    logOpenSyslog("paraNode", optionVal("logFacility", NULL));
logSetMinPriority(optionVal("logMinPriority", "info"));
logInfo("starting paraNode on %s", hostName);

/* Make job lists. */
jobsRunning = newDlList();
jobsFinished = newDlList();

/* Set up socket and self to listen to it. */
ZeroVar(&sai);
sai.sin_family = AF_INET;
sai.sin_port = htons(paraNodePort);
sai.sin_addr.s_addr = INADDR_ANY;
mainRudp = rudpMustOpenBound(&sai);
mainRudp->maxRetries = 12;

/* Event loop. */
findNow();
for (;;)
    {
    /* Get next incoming message and optionally check to make
     * sure that it's from a host we trust, and check signature
     * on first bit of incoming data. */
    if (pmReceive(&pmIn, mainRudp))
	{
	findNow();
	if (hubName == NULL || ntohl(pmIn.ipAddress.sin_addr.s_addr) == hubIp 
		|| ntohl(pmIn.ipAddress.sin_addr.s_addr) == localIp)
	    {
	    /* Host and signature look ok,  read a string and
	     * parse out first word as command. */
	    line = pmIn.data;
	    logDebug("message from %s: \"%s\"",
                     paraFormatIp(ntohl(pmIn.ipAddress.sin_addr.s_addr)),
                     line);
	    command = nextWord(&line);
	    if (command != NULL)
		{
		if (sameString("quit", command))
		    break;
		else if (sameString("run", command))
		    doRun(line, &pmIn.ipAddress);
		else if (sameString("jobDone", command))
		    jobDone(line);
		else if (sameString("status", command))
		    doStatus();
		else if (sameString("kill", command))
		    doKill(line);
		else if (sameString("check", command))
		    doCheck(line, &pmIn.ipAddress);
		else if (sameString("resurrect", command))
		    doResurrect(line, &pmIn.ipAddress);
		else if (sameString("listJobs", command))
		    listJobs();
		else if (sameString("fetch", command))
		    doFetch(line);
                else
                    logWarn("invalid command: \"%s\"", command);
		}
	    logDebug("done command");
	    }
	else
	    {
	    logWarn("command from unauthorized host %s",
                    paraFormatIp(ntohl(pmIn.ipAddress.sin_addr.s_addr)));
	    }
	}
    }
rudpClose(&mainRudp);
}
Exemplo n.º 25
0
/*!
    Renders the delegate using the given \a painter and style \a option for
    the item specified by \a index.

    When reimplementing this function in a subclass, you should update the area
    held by the option's \l{QStyleOption::rect}{rect} variable, using the
    option's \l{QStyleOption::state}{state} variable to determine the state of
    the item to be displayed, and adjust the way it is painted accordingly.

    For example, a selected item may need to be displayed differently to
    unselected items, as shown in the following code:

    \snippet itemviews/pixelator/pixeldelegate.cpp 2
    \dots

    After painting, you should ensure that the painter is returned to its
    the state it was supplied in when this function was called. For example,
    it may be useful to call QPainter::save() before painting and
    QPainter::restore() afterwards.

    \sa QStyle::State
*/
void QItemDelegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    Q_D(const QItemDelegate);
    Q_ASSERT(index.isValid());

    QStyleOptionViewItem opt = setOptions(index, option);

    // prepare
    painter->save();
    if (d->clipPainting)
        painter->setClipRect(opt.rect);

    // get the data and the rectangles

    QVariant value;

    QPixmap pixmap;
    QRect decorationRect;
    value = index.data(Qt::DecorationRole);
    if (value.isValid()) {
        // ### we need the pixmap to call the virtual function
        pixmap = decoration(opt, value);
        if (value.type() == QVariant::Icon) {
            d->tmp.icon = qvariant_cast<QIcon>(value);
            d->tmp.mode = d->iconMode(option.state);
            d->tmp.state = d->iconState(option.state);
            const QSize size = d->tmp.icon.actualSize(option.decorationSize,
                                                      d->tmp.mode, d->tmp.state);
            decorationRect = QRect(QPoint(0, 0), size);
        } else {
            d->tmp.icon = QIcon();
            decorationRect = QRect(QPoint(0, 0), pixmap.size());
        }
    } else {
        d->tmp.icon = QIcon();
        decorationRect = QRect();
    }

    QString text;
    QRect displayRect;
    value = index.data(Qt::DisplayRole);
    if (value.isValid() && !value.isNull()) {
        text = QItemDelegatePrivate::valueToText(value, opt);
        displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text);
    }

    QRect checkRect;
    Qt::CheckState checkState = Qt::Unchecked;
    value = index.data(Qt::CheckStateRole);
    if (value.isValid()) {
        checkState = static_cast<Qt::CheckState>(value.toInt());
        checkRect = doCheck(opt, opt.rect, value);
    }

    // do the layout

    doLayout(opt, &checkRect, &decorationRect, &displayRect, false);

    // draw the item

    drawBackground(painter, opt, index);
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, decorationRect, pixmap);
    drawDisplay(painter, opt, displayRect, text);
    drawFocus(painter, opt, displayRect);

    // done
    painter->restore();
}
Exemplo n.º 26
0
vfs::Path::Path(const wchar_t* sPath)
: _path(sPath)
{
	doCheck();
}
void domult(int Block_RowIndex,int Block_ColIndex)
{
        int i,j,k;
        float omp_tv_start, omp_tv_end;

        int nThreads ;
        int nIter =1;
        int Rows_Size = Block_Of_Row;
        int Columns_Size = Total_Row;

        /* .....Declared Global Variables block_of_row and nRows  ... */
        /* MATRIX A OF SIZE "block_of_row X nRows" is multiplied with 
           MATRIX B OF SIZE "nRows X block_of_row"  */

        omp_tv_start = omp_get_wtime();
        printf("\nbufferA having index %d\t bufferB having index %d\n ", \
                 Block_RowIndex/Block_Of_Row,Block_ColIndex/Block_Of_Row);

        double aveTime, minTime = 1e6, maxTime =0.0;
        for (int i=0; i < nIter; i++) {
        double startTime = dsecnd();

        nThreads =Total_Thread;
        omp_set_num_threads(nThreads);

          /* .........OpenMP  implementaiton  ......*/
          /* ... Modified by vcvr  June 29-2013  ...*/
          #pragma omp parallel default (none) \
                      shared (bufferA, bufferB, bufferC, Rows_Size, Columns_Size) \
                      private(i, j, k) \

          #pragma omp for schedule(static)
          for(i=0; i<Rows_Size; i++)
          {
         //    printf(" Thread %d executes Outer loop iteration %d \n", \
                  omp_get_thread_num(), i);

            for(j=0; j<Rows_Size ; j++)
            {
             bufferC[i*Rows_Size+j] = 0.0;
              for(k = 0; k< Columns_Size ; k++)
                bufferC[i*Rows_Size + j]  += \
                (bufferA[i*Rows_Size + k])* (bufferB[j*Rows_Size + k]);
           }
          } /* --- End of omp parallel for --- */

        double endTime = dsecnd();
        double runtime = endTime - startTime;

        maxTime = (maxTime > runtime)? maxTime:runtime;
        minTime = (minTime < runtime)? minTime:runtime;

        aveTime += runtime;
     }  /* .... Average Gflops routine .... */
    aveTime /= nIter;

    omp_tv_end = omp_get_wtime();
    printf("\n\t\t Time taken ( do Mult)    :  %lf sec", (omp_tv_end - omp_tv_start));

    /* ...........Verfication of Matrix-Matrix Multiplication results ............*/
    #pragma omp parallel 
    #pragma omp master  
    printf("nThreads : %d    ITR : %d", omp_get_num_threads(), nIter);

   #pragma omp barrier   

    // do check   
    double error = 0.f;

  double mklGflop = doCheck(Rows_Size, Columns_Size,\
                             bufferA,bufferB,bufferC, nIter,&error);  
    printf("  mklGflop : %g Root_Mean_Error: %g ", mklGflop,error);    


    printf("\n");

    printf(" nThrds %d matrix Rows-A %d matrix Columns-A %d matrix Rows-B %d matrix Columns-B %d \ 
             maxRT %g minRT %g aveRT %g  ave_GFlop/s % g\n",  \
             omp_get_num_threads(), Rows_Size, Columns_Size, Columns_Size, Rows_Size, \
             maxTime, minTime, aveTime, 2e-9*Rows_Size*Columns_Size*Rows_Size/aveTime);



}
Exemplo n.º 28
0
vfs::Path::Path(vfs::String const& sPath)
: _path(sPath.c_wcs())
{
	doCheck();
}
Exemplo n.º 29
0
 /**
  * @param root: The root of binary tree.
  * @return: True if this Binary tree is Balanced, or false.
  */
 bool isBalanced(TreeNode *root) {
     // write your code here
     return doCheck(root) < 0 ? false : true;
 }