Beispiel #1
0
void BitPumpJPEG::setAbsoluteOffset(unsigned int offset) {
  if (offset >= size)
    throw IOException("Offset set out of buffer");

  mLeft = 0;
  off = offset;
  _fill();
}
Status TransportLayerLegacy::_runTicket(Ticket ticket) {
    if (!_running.load()) {
        return TransportLayer::ShutdownStatus;
    }

    if (ticket.expiration() < Date_t::now()) {
        return Ticket::ExpiredStatus;
    }

    AbstractMessagingPort* amp;

    {
        stdx::lock_guard<stdx::mutex> lk(_connectionsMutex);

        auto conn = _connections.find(ticket.sessionId());
        if (conn == _connections.end()) {
            return TransportLayer::TicketSessionUnknownStatus;
        }

        // "check out" the port
        conn->second.inUse = true;
        amp = conn->second.amp.get();
    }

    auto legacyTicket = checked_cast<LegacyTicket*>(getTicketImpl(ticket));
    auto res = legacyTicket->_fill(amp);

    {
        stdx::lock_guard<stdx::mutex> lk(_connectionsMutex);

        auto conn = _connections.find(ticket.sessionId());
        invariant(conn != _connections.end());

#ifdef MONGO_CONFIG_SSL
        // If we didn't have an X509 subject name, see if we have one now
        if (!conn->second.sslPeerInfo) {
            auto info = amp->getX509PeerInfo();
            if (info.subjectName != "") {
                conn->second.sslPeerInfo = info;
            }
        }
#endif
        conn->second.inUse = false;

        if (conn->second.ended) {
            Listener::globalTicketHolder.release();
            _connections.erase(conn);
        }
    }

    return res;
}
Beispiel #3
0
GError*
meta0_backend_fill(struct meta0_backend_s *m0, guint replicas, gchar **m1urls)
{
	struct sqlx_sqlite3_s *sq3 = NULL;
	GError *err;
	gchar **u = NULL;

	EXTRA_ASSERT(m0 != NULL);
	EXTRA_ASSERT(replicas < 65535);
	EXTRA_ASSERT(m1urls != 0);

	u = g_strdupv(m1urls);
	err = _open_and_lock(m0, M0V2_OPENBASE_MASTERONLY, &sq3);
	if (!err) {
		err = _fill(sq3,replicas,u);
		_unlock_and_close(sq3);
	}

	g_strfreev(u);
	return err;
}
Beispiel #4
0
void _draw_listview(
		LPDRAWITEMSTRUCT itst
	)
{
	DRAWTEXTPARAMS dtp         = { sizeof(dtp) };
	LVCOLUMN       lvc         = { sizeof(lvc) };
	wchar_t        s_text[200] = { 0 };
	int            cx, cy, k   = 0;
	int            offset      = 0;
	int            icon;
	BOOL           is_root;
	int            col_cnt     = Header_GetItemCount( ListView_GetHeader( itst->hwndItem ) );
	LVITEM         lvitem      = { LVIF_TEXT | LVIF_PARAM, itst->itemID, 0, 0, 0, s_text, countof(s_text) };
	COLORREF       bgcolor     = ListView_GetBkColor( itst->hwndItem );

	ListView_GetItem( itst->hwndItem, &lvitem );
	is_root = _is_root_item( lvitem.lParam );

	{
		void *user_data = wnd_get_long( __lists[HMAIN_DRIVES], GWL_USERDATA );
		if (user_data != NULL)
		{
			MessageBox( __dlg, s_text, NULL, 0 );
		}
	}

	if ( ( itst->itemState & ODS_SELECTED ) && IsWindowEnabled( itst->hwndItem ) /*&& ( lvitem.lParam != NULL )*/ ) 
	{
		if ( GetFocus( ) == itst->hwndItem )
		{
			bgcolor = CL_WHITE;
		} else {
			bgcolor = _cl( COLOR_BTNFACE, 80 );
		}
	}
	if ( is_root ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 60 );
	}
	if ( _is_marked_item(lvitem.lParam) ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 35 );
	}
	
	_fill( itst->hDC, &itst->rcItem, bgcolor );

	for ( ; k < col_cnt; k++ )
	{
		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_IMAGE;
		ListView_GetColumn( itst->hwndItem, k, &lvc );

		itst->rcItem.left  = k ? itst->rcItem.right : 0;
		itst->rcItem.right = itst->rcItem.left + lvc.cx;

		lvitem.iItem       = itst->itemID; 
		lvitem.iSubItem    = k;

		ListView_GetItem( itst->hwndItem, &lvitem );
		dtp.iLeftMargin = dtp.iRightMargin = 5;		

		if ( (!itst->rcItem.left) && _is_icon_show( itst->hwndItem, k ) )
		{
			ImageList_GetIconSize( __dsk_img, &cx, &cy );
			offset = lvitem.lParam && !is_root ? 25 : 3;

			itst->rcItem.left += offset + cy + ( lvitem.lParam && !is_root ? 8 : 4 );
			icon = 0;

			if (! is_root ) 
			{
				if ( _is_splited_item(lvitem.lParam) ) icon = 1;
				if ( _is_cdrom_item(lvitem.lParam) )   icon = 2;
			}

			ImageList_Draw(
				__dsk_img, icon, itst->hDC, offset, itst->rcItem.top + 3, ILD_TRANSPARENT
				);
		} else 
		{
			offset = 0;
		}
		if ( offset && is_root )
		{
			DrawState(
				itst->hDC, 0, NULL, (LPARAM)s_text, 0, 
				itst->rcItem.left+5, itst->rcItem.top, 0, 0, DST_PREFIXTEXT | DSS_MONO
				);
		} else 
		{
			if ( wcslen(s_text) != 0 ) 
			{
				COLORREF text_color = GetSysColor( COLOR_WINDOWTEXT );

				if ( !_is_active_item(lvitem.lParam) )
				{
					text_color = GetSysColor( COLOR_GRAYTEXT );
				}
				SetTextColor( itst->hDC, text_color );

				if ( k >= 4 )
				{
					SelectObject( itst->hDC, __font_bold );
				}
				if ( !IsWindowEnabled( itst->hwndItem ) )
				{
					SetTextColor( itst->hDC, GetSysColor(COLOR_GRAYTEXT) );

					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
				} else 
				{
					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
					/*
					if ( GetFocus( ) == itst->hwndItem )
					{
						DrawFocusRect( itst->hDC, &itst->rcItem );
					}
					*/
				}
			}
		}
	}							
}
Beispiel #5
0
void ICanvas::fill() {
  checkInitialized();
  _fill();
}
Status TransportLayerLegacy::LegacyTicket::fill(AbstractMessagingPort* amp) {
    return _fill(amp);
}
Beispiel #7
0
void _draw_static(
		LPDRAWITEMSTRUCT itst
	)
{
	UINT edge   = BDR_RAISEDINNER;
	UINT state  = DSS_NORMAL;
	UINT border = BF_RECT;

	DRAWTEXTPARAMS tp = { sizeof(tp) };
	WINDOWINFO wi;
	RECT rc;

	_wnd_data *gwl;
	_tab_data *tab;

	wchar_t data[MAX_PATH];
	int x = 6, y = 3;
	char curr;	

	if ( !itst ) return;
	switch ( itst->CtlType )
	{
		case ODT_LISTVIEW: _draw_listview(itst); break;
		case ODT_COMBOBOX: _draw_combobox(itst); break;
		case ODT_TAB:      _draw_tabs(itst);     break;

		case ODT_BUTTON:

        if ( itst->itemState & ODS_DISABLED ) state = DSS_DISABLED;
        if ( itst->itemState & ODS_SELECTED )
		{
			edge = BDR_SUNKENOUTER;
			x++; y++;
        }
		itst->rcItem.top++;

		GetWindowText( itst->hwndItem, data, MAX_PATH );
		GetClientRect( itst->hwndItem, &rc );

		gwl = wnd_get_long( itst->hwndItem, GWL_USERDATA );
		tab = wnd_get_long( GetParent(itst->hwndItem), GWL_USERDATA );

		curr = tab && ( tab->h_curr == itst->hwndItem );

		if ( gwl )
		{
			if ( !gwl->dlg[0] )
			{
				itst->rcItem.right  = itst->rcItem.left + 13;
				itst->rcItem.bottom = itst->rcItem.top  + 13;

				_fill( itst->hDC, &rc, _cl(COLOR_BTNFACE, FALSE) );
				_fill( itst->hDC, &itst->rcItem, /* (itst->itemState & ODS_FOCUS) ? _cl(COLOR_BTNFACE, FALSE) : */ _cl(COLOR_BTNFACE, LGHT_CLR) );

				GetWindowText(itst->hwndItem, data, MAX_PATH);
				if ( gwl->state )
				{
					ImageList_DrawEx(
						__img, 0, itst->hDC, itst->rcItem.right - 11, 2, 0, 0, CLR_NONE, GetSysColor(COLOR_BTNSHADOW), ILD_BLEND
					);
				}
				DrawEdge(
					itst->hDC, &itst->rcItem, BDR_SUNKENOUTER, border
					);
				DrawState(
					itst->hDC, NULL, NULL, (LPARAM)data, 0, itst->rcItem.right+4, 0, 0, 0, DST_PREFIXTEXT | state
					);

				if ( itst->itemState & ODS_FOCUS )
				{
					rc.bottom  = itst->rcItem.bottom - itst->rcItem.top + 2;					
					rc.left   += itst->rcItem.right + 2;

					DrawFocusRect( itst->hDC, &rc );
				}
				return;
			} else 
			{ 
				if ( curr )
				{							
					edge = BDR_SUNKENOUTER;
					x++; y++;
				} else {
					border = BF_FLAT;
				}
			}
		}

		_fill( itst->hDC, &itst->rcItem, (itst->itemState & ODS_FOCUS ) ?
			_cl( COLOR_BTNFACE, DARK_CLR ) :
			_cl( COLOR_BTNFACE, FALSE ) );

		DrawState( itst->hDC, NULL, NULL, (LPARAM)data, 0, x, y, 0, 0, DST_PREFIXTEXT | state );
		if ( itst->itemState & ODS_FOCUS )
		{
			modify_rect( rc, 1, 2, -2, -2 );
			if ( itst->itemState & ODS_SELECTED )
			{
				modify_rect( rc, 1, 1, 1, 1 );
			}
			DrawFocusRect( itst->hDC, &rc );
		}

		case ODT_STATIC:
		{
			GetWindowInfo(itst->hwndItem, &wi);
			GetWindowText(itst->hwndItem, data, MAX_PATH);

			if ( data[0] == L'#' )
			{
				GetWindowRect(GetParent(GetParent(itst->hwndItem)), &rc);

				itst->rcItem.right = rc.right - rc.left - 3;
				itst->rcItem.top = itst->rcItem.left = 1;

				_fill(itst->hDC, &itst->rcItem, _cl(COLOR_BTNSHADOW, DARK_CLR - 7));

				tp.iLeftMargin   += 10;
				itst->rcItem.top += 1;

				DrawTextEx(itst->hDC, data + 1, -1, &itst->rcItem, DT_END_ELLIPSIS, &tp);					
			}
			else 
			{
				if ( (wi.dwStyle & SS_SUNKEN) == 0 )
				{
					DrawEdge(itst->hDC, &itst->rcItem, edge, border);				
				}
			}
		}
		break;
	}
}
Beispiel #8
0
/*!
 * \brief create a _Beziergon or _StdPath from the graphics state
 * \todo respect FILL_RULE_EVEN_ODD
 */
void
DiaOutputDev::eoFill (GfxState *state)
{
  _fill (state, false);
}
gint main (gint argc, gchar ** argv)
{
  gint ret = 0;

  VsgPRTree2d *tree;

  VsgVector2d lb;
  VsgVector2d ub;
  GTimer *timer = NULL;

  MPI_Init (&argc, &argv);

  MPI_Comm_size (MPI_COMM_WORLD, &sz);
  MPI_Comm_rank (MPI_COMM_WORLD, &rk);

  vsg_init_gdouble ();

  parse_args (argc, argv);

  if (nc_padding > 0)
    {
      if (_verbose && rk == 0)
        g_printerr ("%d: NodeCounter padding: %d\n", rk, nc_padding);
      _nc_padding_buffer = g_malloc (nc_padding * sizeof (char));
    }

  points = g_ptr_array_new ();

  lb.x = -1.; lb.y = -1.;
  ub.x = 1.; ub.y = 1.;

  /* create the tree */
  tree =
    vsg_prtree2d_new_full (&lb, &ub,
                           (VsgPoint2dLocFunc) vsg_vector2d_vector2d_locfunc,
                           (VsgPoint2dDistFunc) vsg_vector2d_dist,
                           NULL, _maxbox);

  if (_hilbert)
    {
      /* configure for hilbert curve order traversal */
      vsg_prtree2d_set_children_order_hilbert (tree);
    }

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: set_parallel begin\n", rk);
    }

  vsg_prtree2d_set_parallel (tree, &pconfig);

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: set_parallel ok\n", rk);
    }

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: fill begin\n", rk);
    }

  _fill (tree, _np);

/*   /\* try one exterior point *\/ */
/*   if (sz > 1) */
/*     { */
/*       if (rk == 1) */
/*         { */
/*           Pt *pt; */

/*           _ref_count += _np+1; */

/*           pt = pt_alloc (TRUE, NULL); */
/*           pt->vector.x = ub.x+1.; */
/*           pt->vector.y = ub.y+1.; */
/*           pt->weight = _np+1; */

/*           vsg_prtree2d_insert_point (tree, pt); */
/*         } */
/*       else */
/*         { */
/*           _ref_count += _np+1; */
/*         } */

/*       vsg_prtree2d_migrate_flush (tree); */
/*       _distribute (tree); */
/*     } */


  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: fill ok\n", rk);
    }

  if (_do_write)
    {
      gchar fn[1024];
      FILE *f;

      sprintf (fn, "comm-%03d.svg", rk);
      f = fopen (fn, "w");

      fprintf (f, "\n<g style=\"stroke-width:0.01; stroke:black; " \
               "fill:none\">\n");
      fclose (f);
    }

  if (_verbose)
    {
      g_printerr ("%d: near/far traversal begin\n", rk);
          MPI_Barrier (MPI_COMM_WORLD);
      timer = g_timer_new ();
    }

  /* accumulate the point counts across the tree */
  _do_upward_pass (tree);

  /* do some near/far traversal */
  vsg_prtree2d_near_far_traversal (tree, (VsgPRTree2dFarInteractionFunc) _far,
                                   (VsgPRTree2dInteractionFunc) _near,
                                   &ret);
  /* accumulate from top to leaves */
  vsg_prtree2d_traverse (tree, G_PRE_ORDER, (VsgPRTree2dFunc) _down, NULL);

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);

      g_printerr ("%d: near/far traversal ok elapsed=%f seconds\n", rk,
                  g_timer_elapsed (timer, NULL));

      g_timer_destroy (timer);
    }

  if (_do_write)
    {
      gchar fn[1024];
      FILE *f;

      MPI_Barrier (MPI_COMM_WORLD);

      g_sprintf (fn, "prtree2parallel-%03d.txt", rk);
      f = fopen (fn, "w");
      vsg_prtree2d_write (tree, f);
      fclose (f);

      _tree_write (tree, "prtree2parallel-");
    }

  if (_do_write)
    {
      gchar fn[1024];
      FILE *f;

      sprintf (fn, "comm-%03d.svg", rk);
      f = fopen (fn, "a");
      fprintf (f, "</g>\n");
      fclose (f);
    }

  if (_verbose)
    {
      gint near_count_sum, far_count_sum;
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: processor msg stats fw=%d bw=%d\n",
                  rk, _fw_count, _bw_count);
      g_printerr ("%d: processor call stats near=%d far=%d\n",
                  rk, _near_count, _far_count);

      MPI_Reduce (&_near_count, &near_count_sum, 1, MPI_INT, MPI_SUM, 0,
                  MPI_COMM_WORLD);
      MPI_Reduce (&_far_count, &far_count_sum, 1, MPI_INT, MPI_SUM, 0,
                  MPI_COMM_WORLD);
      if (rk == 0)
        {
          g_printerr ("%d: mean call stats near=%f far=%f\n",
                      rk, (1.*near_count_sum)/sz, (1.*far_count_sum)/sz);
        }
    }

  /* check correctness of results */
  g_ptr_array_foreach (points, (GFunc) _check_pt_count,
                       &_ref_count);

  /* destroy the points */
  g_ptr_array_foreach (points, empty_array, NULL);
  g_ptr_array_free (points, TRUE);

  /* destroy the tree */
  vsg_prtree2d_free (tree);

  if (nc_padding > 0) g_free (_nc_padding_buffer);

  MPI_Finalize ();

  return ret;
}
Beispiel #10
0
/*!
 * \brief create a _BezierShape or _StdPath from the graphics state
 * \todo respect FILL_RULE_WINDING
 */
void
DiaOutputDev::fill (GfxState *state)
{
  _fill (state, true);
}
Beispiel #11
0
gint main (gint argc, gchar ** argv)
{
  gint ret = 0;

  VsgVector2d lb = {-1., -1.};
  VsgVector2d ub = {1., 1.};

  VsgPRTree2d *tree;
  VsgPRTree2d *treeref;
  gint i;
  gint ref_far_count;

  vsg_init_gdouble ();

  parse_args (argc, argv);

#ifdef VSG_HAVE_MPI
  if (_mpi)
    {
      MPI_Init (&argc, &argv);

      MPI_Comm_size (MPI_COMM_WORLD, &sz);
      MPI_Comm_rank (MPI_COMM_WORLD, &rk);

      if (counts != NULL)
        {
          gint i = 0;
          gint tmp = 0;

          while (counts[i+1] != NULL && i<rk) i ++;

	  if (sscanf (counts[i], "%u", &tmp) == 1)
            _expect_far_count = tmp;
	  else
	    test_printerr ("Invalid expected far count list (--expect-far-counts)\n");

          g_strfreev (counts);
        }
    }
#endif

  points_array = g_ptr_array_new ();

  if (rk == 0) _fill (&_npoints, points_array);
  else _npoints = 0;

  pointsref_array = g_ptr_array_sized_new (_npoints);
  for (i=0; i<_npoints; i++)
    {
      Pt *ptref = pt_alloc (TRUE, pointsref_array);
      memcpy (ptref, (Pt *) g_ptr_array_index (points_array, i), sizeof (Pt));
    }

  /* create the trees */
  tree =
    vsg_prtree2d_new_full (&lb, &ub,
                           (VsgPoint2dLocFunc) vsg_vector2d_vector2d_locfunc,
                           (VsgPoint2dDistFunc) vsg_vector2d_dist,
                           NULL, _maxbox);
  treeref = vsg_prtree2d_clone (tree);

  vsg_prtree2d_set_nf_isleaf (tree, _nf_isleaf_virtual_maxbox,
                              &_virtual_maxbox);

  vsg_parallel_vtable_set (&pconfig.node_data,
                           node_counter_alloc, NULL,
                           node_counter_destroy, NULL);
  vsg_prtree2d_set_node_data_vtable (tree, &pconfig.node_data);

  vsg_parallel_vtable_set (&prefconfig.node_data,
                           node_counter_alloc, NULL,
                           node_counter_destroy, NULL);
  vsg_prtree2d_set_node_data_vtable (treeref, &prefconfig.node_data);

#ifdef VSG_HAVE_MPI

  if (_mpi)
    {
      vsg_parallel_vtable_set (&pconfig.point,
                               pt_alloc, points_array,
                               pt_destroy, points_array);

      vsg_parallel_vtable_set (&prefconfig.point,
                               pt_alloc, pointsref_array,
                               pt_destroy, pointsref_array);

      vsg_parallel_vtable_set_parallel (&pconfig.point,
                                        pt_migrate_pack, NULL,
                                        pt_migrate_unpack, NULL,
                                        NULL, NULL,
                                        pt_visit_fw_pack, NULL,
                                        pt_visit_fw_unpack, NULL,
                                        NULL, NULL,
                                        pt_visit_bw_pack, NULL,
                                        pt_visit_bw_unpack, NULL,
                                        pt_visit_bw_reduce, NULL);

      vsg_parallel_vtable_set_parallel (&pconfig.node_data,
                                        nc_migrate_pack, NULL,
                                        nc_migrate_unpack, NULL,
                                        NULL, NULL,
                                        nc_visit_fw_pack, NULL,
                                        nc_visit_fw_unpack, NULL,
                                        nc_visit_fw_reduce, NULL,
                                        nc_visit_bw_pack, NULL,
                                        nc_visit_bw_unpack, NULL,
                                        nc_visit_bw_reduce, NULL);

      vsg_parallel_vtable_set_parallel (&prefconfig.point,
                                        pt_migrate_pack, NULL,
                                        pt_migrate_unpack, NULL,
                                        NULL, NULL,
                                        pt_visit_fw_pack, NULL,
                                        pt_visit_fw_unpack, NULL,
                                        NULL, NULL,
                                        pt_visit_bw_pack, NULL,
                                        pt_visit_bw_unpack, NULL,
                                        pt_visit_bw_reduce, NULL);

      vsg_parallel_vtable_set_parallel (&prefconfig.node_data,
                                        nc_migrate_pack, NULL,
                                        nc_migrate_unpack, NULL,
                                        NULL, NULL,
                                        nc_visit_fw_pack, NULL,
                                        nc_visit_fw_unpack, NULL,
                                        nc_visit_fw_reduce, NULL,
                                        nc_visit_bw_pack, NULL,
                                        nc_visit_bw_unpack, NULL,
                                        nc_visit_bw_reduce, NULL);

      vsg_prtree_parallel_config_set_communicator (&pconfig, MPI_COMM_WORLD);
      vsg_prtree_parallel_config_set_communicator (&prefconfig, MPI_COMM_WORLD);

      vsg_prtree2d_set_parallel (tree, &pconfig);

      vsg_prtree2d_set_parallel (treeref, &prefconfig);
    }
#endif

  /* insert points */
  for (i=0; i<_npoints; i++)
    {
      if (_verbose)
	{
	  test_printerr ("points[%d]: ", i);
	  vsg_vector2d_write (g_ptr_array_index (points_array, i), stderr);
	  g_printerr ("\n");
	}

      vsg_prtree2d_insert_point (tree, g_ptr_array_index (points_array, i));
      vsg_prtree2d_insert_point (treeref,
                                 g_ptr_array_index (pointsref_array, i));
    }

#ifdef VSG_HAVE_MPI
  if (_mpi)
    {
      vsg_prtree2d_migrate_flush (tree);
      vsg_prtree2d_migrate_flush (treeref);

      vsg_prtree2d_distribute_contiguous_leaves (tree);
      vsg_prtree2d_distribute_contiguous_leaves (treeref);
    }
#endif

  if (_write)
    {
      gchar fn[128];
      FILE *f;

      g_sprintf (fn, "tree-%03d.txt", rk);
      f = fopen (fn, "w");
      vsg_prtree2d_write (tree, f);
      fclose (f);
      g_sprintf (fn, "treeref-%03d.txt", rk);
      f = fopen (fn, "w");
      vsg_prtree2d_write (treeref, f);
      fclose (f);
    }

  /* compute neaf/far interactions for treeref */
  _far_count = 0;
  _do_upward_pass (treeref);
  vsg_prtree2d_near_far_traversal (treeref, (VsgPRTree2dFarInteractionFunc) _far,
                                   (VsgPRTree2dInteractionFunc) _near,
                                   &ret);
  vsg_prtree2d_traverse (treeref, G_PRE_ORDER, (VsgPRTree2dFunc) _down, NULL);
  ref_far_count = _far_count;

  /* compute neaf/far interactions for tree */
  _far_count = 0;
  _do_upward_pass (tree);
  vsg_prtree2d_near_far_traversal (tree, (VsgPRTree2dFarInteractionFunc) _far,
                                   (VsgPRTree2dInteractionFunc) _near,
                                   &ret);
  vsg_prtree2d_traverse (tree, G_PRE_ORDER, (VsgPRTree2dFunc) _down, NULL);

#ifdef VSG_HAVE_MPI
  if (_mpi)
    {
      /* migrate points back to processor 0 before checking */
      vsg_prtree2d_distribute_concentrate (tree, 0);
      vsg_prtree2d_distribute_concentrate (treeref, 0);
    }
#endif

  /* check results */
  for (i=0; i<points_array->len; i++)
    {
      Pt *pt = g_ptr_array_index (points_array, i);
      /* FIXME: what if pointsref and points are no longer in the same order? */
      Pt *ptref = g_ptr_array_index (pointsref_array, i);

      if (pt->count != ptref->count)
        {
          test_printerr ("error pt[");
          vsg_vector2d_write (&pt->vector, stderr);
          g_printerr ("]=%ld ptref[", pt->count);
          vsg_vector2d_write (&ptref->vector, stderr);
          g_printerr ("]=%ld\n", ptref->count);
        }
      else if (_verbose)
        {
          test_printerr ("correct comparison [");
          vsg_vector2d_write (&pt->vector, stderr);
          g_printerr ("]=%ld ptref[", pt->count);
          vsg_vector2d_write (&ptref->vector, stderr);
          g_printerr ("]=%ld\n", ptref->count);
        }
    }

  if ((_expect_far_count >= 0) && (_expect_far_count != _far_count))
    test_printerr ("far_count=%d != expected far_count=%d (ref=%d)\n",
                   _far_count, _expect_far_count, ref_far_count);
  else if (_verbose)
    test_printerr ("far_count=%d == expected far_count=%d (ref=%d)\n",
                   _far_count, _expect_far_count, ref_far_count);

  /* remove the points */
  for (i=0; i<points_array->len; i++)
    {
      vsg_prtree2d_remove_point (tree, g_ptr_array_index (points_array, i));
      vsg_prtree2d_remove_point (treeref,
                                 g_ptr_array_index (pointsref_array, i));
    }

  /* destroy the trees */
  vsg_prtree2d_free (tree);
  vsg_prtree2d_free (treeref);

  for (i=0; i<points_array->len; i++)
    pt_destroy (g_ptr_array_index (points_array, i), FALSE, points_array);

  for (i=0; i<pointsref_array->len; i++)
    pt_destroy (g_ptr_array_index (pointsref_array, i), FALSE, pointsref_array);


  g_ptr_array_free (points_array, TRUE);
  g_ptr_array_free (pointsref_array, TRUE);

#ifdef VSG_HAVE_MPI
  if (_mpi)
    MPI_Finalize ();
#endif

  return ret;
}
int main (int argc, char **argv)
{
#ifdef VSG_HAVE_MPI
  VsgPRTreeParallelConfig pconfig = {{NULL,}};
#endif

  VsgVector3d lbound = {-TR, -TR, -TR};
  VsgVector3d ubound = {TR, TR, TR};
  VsgPRTree3d *prtree;
  AranSolver3d *solver;
  int ret = 0;
  GTimer *timer = NULL;

#ifdef VSG_HAVE_MPI
  MPI_Init (&argc, &argv);

  MPI_Comm_size (MPI_COMM_WORLD, &sz);
  MPI_Comm_rank (MPI_COMM_WORLD, &rk);
#endif

  aran_init();

  parse_args (argc, argv);

#ifdef VSG_HAVE_MPI
  pconfig.communicator = MPI_COMM_WORLD;

  pconfig.point = point_accum_vtable;

  aran_development3d_vtable_init (&pconfig.node_data, 0, order);
#endif

  points = g_ptr_array_new ();

  if (check)
    {
      _cp_size = MAX (np, 128);
      check_points = g_malloc0 (_cp_size * sizeof (PointAccum));
    }

  prtree =
    vsg_prtree3d_new_full (&lbound, &ubound,
                            (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                            (VsgPoint3dDistFunc) vsg_vector3d_dist,
                            (VsgRegion3dLocFunc) NULL, maxbox);

  solver = aran_solver3d_new (prtree, ARAN_TYPE_DEVELOPMENT3D,
                              aran_development3d_new (0, order),
                              (AranZeroFunc) aran_development3d_set_zero);

#ifdef VSG_HAVE_MPI
  aran_solver3d_set_parallel (solver, &pconfig);
#endif

  aran_solver3d_set_functions (solver,
                               (AranParticle2ParticleFunc3d) p2p,
                               (AranParticle2MultipoleFunc3d) p2m,
                               m2m,
                               m2l,
                               l2l,
                               (AranLocal2ParticleFunc3d) l2p);

  if (_hilbert)
    {
      /* configure for hilbert curve order traversal */
      aran_solver3d_set_children_order_hilbert (solver);
    }

  _fill (solver);

/*   g_printerr ("ok depth = %d size = %d\n", */
/*               aran_solver3d_depth (solver), */
/*               aran_solver3d_point_count (solver)); */

  if (_verbose)
    {
      g_printerr ("%d : solve begin\n", rk);

#ifdef VSG_HAVE_MPI
      MPI_Barrier (MPI_COMM_WORLD);
#endif

      timer = g_timer_new ();
    }

  aran_solver3d_solve (solver);

  if (_verbose)
    {
#ifdef VSG_HAVE_MPI
      MPI_Barrier (MPI_COMM_WORLD);
#endif

      g_printerr ("%d : solve ok elapsed=%f seconds\n", rk,
                  g_timer_elapsed (timer, NULL));

      g_timer_destroy (timer);
    }

  if (_write)
    {
      gchar fn[1024];
      FILE *f;

      g_sprintf (fn, "tree%03d.txt", rk);
      f = fopen (fn, "w");
      vsg_prtree3d_write (prtree, f);
      fclose (f);

      _tree_write (prtree, "solv");
      _vtp_tree_write (solver, "solv");
    }

  if (check)
    {
      gint i, j;

      if (sz == 1)
        {
          for (i=0; i<np; i ++)
            {
              PointAccum *pi = &check_points[i];

              for (j=0; j<np; j ++)
                {
                  if (j != i)
                    {
                      PointAccum *pj = &check_points[j];
                      p2p_one_way (pi, pj);
                    }
                }

            }
        }
      else
        check_parallel_points (solver);

      aran_solver3d_foreach_point (solver, (GFunc) check_point_field, &ret);

      if (_verbose)
        g_printerr ("%d : max err = %e\n", rk, maxerr);

      g_free (check_points);
    }

  aran_solver3d_free (solver);

#ifdef VSG_HAVE_MPI
  aran_development3d_vtable_clear (&pconfig.node_data);
#endif

  g_ptr_array_free (points, TRUE);

  if (_load_file != NULL) g_free (_load_file);

#ifdef VSG_HAVE_MPI
  MPI_Finalize ();
#endif

  return ret;
}
Beispiel #13
0
gint main (gint argc, gchar ** argv)
{
  gint ret = 0;

  VsgPRTree3d *tree;

  VsgVector3d lb;
  VsgVector3d ub;


  MPI_Init (&argc, &argv);

  MPI_Comm_size (MPI_COMM_WORLD, &sz);
  MPI_Comm_rank (MPI_COMM_WORLD, &rk);

  vsg_init_gdouble ();

  parse_args (argc, argv);

  points = g_ptr_array_new ();
  regions = g_ptr_array_new ();

  lb.x = -1.; lb.y = -1.; lb.z = -1.;
  ub.x = 1.; ub.y = 1.; ub.z = 1.;

  /* create the tree */
  tree =
    vsg_prtree3d_new_full (&lb, &ub,
                           (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                           (VsgPoint3dDistFunc) vsg_vector3d_dist,
                           (VsgRegion3dLocFunc) _sphere_loc3, 2);

  if (_hilbert)
    {
      /* configure for hilbert curve order traversal */
      vsg_prtree3d_set_children_order_hilbert (tree);
    }

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: set_parallel begin\n", rk);
    }

  vsg_prtree3d_set_parallel (tree, &pconfig);

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: set_parallel ok\n", rk);
    }

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: fill begin\n", rk);
    }

  _fill (tree, _np);

  _check_local_counts (tree);

  if (_verbose)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      g_printerr ("%d: fill ok\n", rk);
    }

  /* update total points and regions count */
  init_total_points_count ();
  init_total_regions_count ();

  if (_scatter_before)
    {
      if (_verbose)
        {
          MPI_Barrier (MPI_COMM_WORLD);
          g_printerr ("%d: scatter nodes begin\n", rk);
        }

      vsg_prtree3d_distribute_scatter_leaves (tree);

      _check_local_counts (tree);

      ret += check_points_number (tree);
      ret += check_regions_number (tree);

      if (_verbose)
        {
          MPI_Barrier (MPI_COMM_WORLD);
          g_printerr ("%d: scatter nodes ok\n", rk);
        }

      _write_regions (tree, "rg-scatter");
      _tree_write (tree, "scatter-");
    }

  if (_do_contiguous)
    {
      if (_verbose)
        {
          MPI_Barrier (MPI_COMM_WORLD);
          g_printerr ("%d: contiguous distribute begin\n", rk);
        }

      vsg_prtree3d_distribute_contiguous_leaves (tree);

      _check_local_counts (tree);

      ret += check_points_number (tree);
      ret += check_regions_number (tree);

      if (_verbose)
        {
          MPI_Barrier (MPI_COMM_WORLD);
          g_printerr ("%d: contiguous distribute ok\n", rk);
        }

      _write_regions (tree, "rg-contiguous");
    }

  _exterior_points (tree);

  vsg_prtree3d_distribute_contiguous_leaves (tree);

  _check_local_counts (tree);

  if (_do_write)
    {
      MPI_Barrier (MPI_COMM_WORLD);
      _tree_write (tree, "prtree3parallel-");
    }

  if (_do_write)
    {
      gchar fn[1024];
      FILE *f;

      g_sprintf (fn, "prtree3parallel-%03d.txt", rk);
      f = fopen (fn, "w");
      vsg_prtree3d_write (tree, f);
      fclose (f);
    }

  /* destroy the points */
  g_ptr_array_foreach (points, empty_array, NULL);
  g_ptr_array_free (points, TRUE);

  /* destroy the spheres */
  g_ptr_array_foreach (regions, empty_array, NULL);
  g_ptr_array_free (regions, TRUE);

  /* destroy the tree */
  vsg_prtree3d_free (tree);

  MPI_Finalize ();

  return ret;
}
Beispiel #14
0
int main (int argc, char **argv)
{
#ifdef VSG_HAVE_MPI
  VsgPRTreeParallelConfig pconfig = {{NULL,}};
#endif

  VsgVector3d lbound = {-TR, -TR, -TR};
  VsgVector3d ubound = {TR, TR, TR};
  VsgPRTree3d *prtree;
  AranSolver3d *solver;
  int ret = 0;
  GTimer *timer = NULL;

#ifdef VSG_HAVE_MPI
  MPI_Init (&argc, &argv);

  MPI_Comm_size (MPI_COMM_WORLD, &sz);
  MPI_Comm_rank (MPI_COMM_WORLD, &rk);
#endif

  aran_init();

  parse_args (argc, argv);

#ifdef VSG_HAVE_MPI
  pconfig.communicator = MPI_COMM_WORLD;

  pconfig.point = point_accum_vtable;

  aran_development3d_vtable_init (&pconfig.node_data, 0, order);
#endif

  /* points = g_ptr_array_new (); */

  if (check)
    {
      _cp_size = MAX (np, 128);
      check_points = g_malloc0 (_cp_size * sizeof (PointAccum));
    }

  prtree =
    vsg_prtree3d_new_full (&lbound, &ubound,
                            (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                            (VsgPoint3dDistFunc) vsg_vector3d_dist,
                            (VsgRegion3dLocFunc) NULL, maxbox);

  solver = aran_solver3d_new (prtree, ARAN_TYPE_DEVELOPMENT3D,
                              aran_development3d_new (0, order),
                              (AranZeroFunc) aran_development3d_set_zero);

#ifdef VSG_HAVE_MPI
  aran_solver3d_set_parallel (solver, &pconfig);
#endif

  if (virtual_maxbox != 0)
    aran_solver3d_set_nf_isleaf (solver, _nf_isleaf_virtual_maxbox,
                                 &virtual_maxbox);

  aran_solver3d_set_functions (solver,
                               (AranParticle2ParticleFunc3d) p2p,
                               (AranParticle2MultipoleFunc3d) p2m,
                               m2m,
                               m2l,
                               l2l,
                               (AranLocal2ParticleFunc3d) l2p);

  if (semifar_threshold < G_MAXUINT)
    {
      aran_solver3d_set_functions_full (solver,
                                        (AranParticle2ParticleFunc3d) p2p,
                                        (AranParticle2MultipoleFunc3d) p2m,
                                        m2m,
                                        m2l,
                                        l2l,
                                        (AranLocal2ParticleFunc3d) l2p,
                                        (AranParticle2LocalFunc3d) p2l,
                                        (AranMultipole2ParticleFunc3d) m2p,
                                        semifar_threshold);

      if (semifar_threshold == 0)
        {
          PointAccum p1 = {{0.1, 0.1, 0.1}, 0.1, {0., 0., 0.}, 0};
          PointAccum p2 = {{-0.1, -0.1, -0.1}, 0.1, {0., 0., 0.}, 1};

          /* compute operators timings to be able to compute optimal solver parameters */
          aran_solver3d_profile_operators (solver, (AranParticleInitFunc3d) point_accum_clear_accum,
                                           &p1, &p2);

          /* alternatively, we could get timings from profile databases */
          /* aran_profile_db_read_file ("./profiledb-newtonfield3.ini", NULL); */
          /* aran_solver3d_db_profile_operators (solver, (gdouble) order); */

        }
      
    }

  if (_hilbert)
    {
      /* configure for hilbert curve order traversal */
      aran_solver3d_set_children_order_hilbert (solver);
    }

  if (_verbose)
    {
      g_printerr ("%d : fill begin\n", rk);
      g_printerr ("%d : memory peak1 count = %u\n", rk, getpeak(0));


#ifdef VSG_HAVE_MPI
      MPI_Barrier (MPI_COMM_WORLD);
#endif

      timer = g_timer_new ();
    }

  _fill (solver);

  if (_verbose)
    {
      g_printerr ("%d : fill elapsed=%f seconds\n", rk,
                  g_timer_elapsed (timer, NULL));

      g_printerr ("%d : tree depth count = %d\n", rk,
                  aran_solver3d_depth (solver));

      g_printerr ("%d : particle count=%d\n", rk,
                  aran_solver3d_point_count (solver));

      g_timer_destroy (timer);
  /* g_mem_profile(); */
    }

  if (_verbose)
    {
      g_printerr ("%d : solve begin\n", rk);
      g_printerr ("%d : memory peak2 count = %u\n", rk, getpeak(0));


#ifdef VSG_HAVE_MPI
      MPI_Barrier (MPI_COMM_WORLD);
#endif

      timer = g_timer_new ();
    }

  aran_solver3d_solve (solver);

  if (_verbose)
    {
#ifdef VSG_HAVE_MPI
      MPI_Barrier (MPI_COMM_WORLD);
#endif

      g_printerr ("%d : solve ok elapsed=%f seconds\n", rk,
                  g_timer_elapsed (timer, NULL));
      g_printerr ("%d : memory peak3 count = %u\n", rk, getpeak(0));


      g_timer_destroy (timer);

      {
        glong zero_count, p2p_count, p2m_count, m2m_count;
        glong m2l_count, l2l_count, l2p_count, p2l_count, m2p_count;
        glong p2p_remote_count, m2l_remote_count;

        aran_solver3d_get_stats (solver, &zero_count,
                                 &p2p_count, &p2m_count,
                                 &m2m_count, &m2l_count,
                                 &l2l_count, &l2p_count,
                                 &p2l_count, &m2p_count,
                                 &p2p_remote_count,
                                 &m2l_remote_count);

        g_printerr ("%d : zero count=%ld\n", rk, zero_count);
        g_printerr ("%d : p2p count=%ld\n", rk, p2p_count);
        g_printerr ("%d : p2p remote count=%ld\n", rk, p2p_remote_count);
        g_printerr ("%d : p2m count=%ld\n", rk, p2m_count);
        g_printerr ("%d : m2m count=%ld\n", rk, m2m_count);
        g_printerr ("%d : m2l count=%ld\n", rk, m2l_count);
        g_printerr ("%d : m2l remote count=%ld\n", rk, m2l_remote_count);
        g_printerr ("%d : l2l count=%ld\n", rk, l2l_count);
        g_printerr ("%d : l2p count=%ld\n", rk, l2p_count);
        g_printerr ("%d : p2l count=%ld\n", rk, p2l_count);
        g_printerr ("%d : m2p count=%ld\n", rk, m2p_count);
      }
    }

  if (_write)
    {
      gchar fn[1024];
      FILE *f;

      g_sprintf (fn, "tree%03d.txt", rk);
      f = fopen (fn, "w");
      vsg_prtree3d_write (prtree, f);
      fclose (f);

      _tree_write (prtree, "solv");
      _vtp_tree_write (solver, "solv");
    }

  if (_save_fma_filename != NULL)
    {
      FILE *file = fopen (_save_fma_filename, "w");
      aran_solver3d_write_fma (solver, file);
      fclose (file);
    }

  if (check)
    {
      guint64 i, j;

      if (sz == 1)
        {
          for (i=0; i<np; i ++)
            {
              PointAccum *pi = &check_points[i];

              for (j=0; j<np; j ++)
                {
                  if (j != i)
                    {
                      PointAccum *pj = &check_points[j];
                      p2p_one_way (pi, pj);
                    }
                }
            }
        }
      else
        check_parallel_points (solver);

      aran_solver3d_foreach_point (solver, (GFunc) check_point_field, &ret);

      if (_verbose)
        g_printerr ("%d : max err = %e\n", rk, maxerr);

      g_free (check_points);
    }

  aran_solver3d_free (solver);

#ifdef VSG_HAVE_MPI
  aran_development3d_vtable_clear (&pconfig.node_data);
#endif

  /* g_ptr_array_free (points, TRUE); */

  if (_load_file != NULL) g_free (_load_file);

#ifdef VSG_HAVE_MPI
  MPI_Finalize ();
#endif

  return ret;
}