<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Pointer to point to object in another computer]]></title><description><![CDATA[<p>Hello.</p>
<p>I develop C++ computational library (adaptive mesh). Now I need to make it parallel (distributed-memory systems, MPI preferred).</p>
<p>My library is based on custom pointers, which sometimes point to &quot;virtual&quot; objects (objects which are results of computation, not real objects in memory).</p>
<p>So, I decided that all that I need is to upgrade these pointers for they to have ability to point to objects in the memory of another machine. The problem is that the object on another machine (dereferenced from such a pointer) must behave like real object!</p>
<p>OK, let us suppose that I added machine address to the pointer class.</p>
<ol>
<li>All pointers will have this additional address. Even those which referring to the local objects. This is overhead. May be I should use 2 pointer classes: &quot;local&quot; and &quot;remote&quot;?</li>
<li>If program trying to dereference pointer, what should pointer do? Copy object from remote machine (I can do it using MPI-2 messaging system) and give a reference to it? But this copied object will not work, because it holds some regular pointers to its members. I need to make a copy of all its members, and members of their members,... the whole subtree need to be copied.</li>
<li>How the object should be modified? The local copy should be returned to the source machine and overwrite the original object?</li>
</ol>
<p>So, may be I need another idea? I can, for example, put all interface of my objects (which can be pointed by remote pointers) into a single function with fixed parameters and fixed return value. Then instead of dereferencing a pointer I can only call this function from the pointer. The pointer will then transfer this call (function arguments) to the target machine, call function on this machine, and return result back to the caller.</p>
<p>Now the problem is that the caller must pack all the data into the fixed arguments of such function, even if object is local. May be it is possible in C++ to pass various parameters with various types into a function, which will transfer them directly to the target interface function if object is local, or pack them and transfer to another machine, if object is remote?</p>
<p>Any advice is appreciated.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/262807/pointer-to-point-to-object-in-another-computer</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 08:37:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/262807.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Mar 2010 16:03:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pointer to point to object in another computer on Thu, 11 Mar 2010 16:03:22 GMT]]></title><description><![CDATA[<p>Hello.</p>
<p>I develop C++ computational library (adaptive mesh). Now I need to make it parallel (distributed-memory systems, MPI preferred).</p>
<p>My library is based on custom pointers, which sometimes point to &quot;virtual&quot; objects (objects which are results of computation, not real objects in memory).</p>
<p>So, I decided that all that I need is to upgrade these pointers for they to have ability to point to objects in the memory of another machine. The problem is that the object on another machine (dereferenced from such a pointer) must behave like real object!</p>
<p>OK, let us suppose that I added machine address to the pointer class.</p>
<ol>
<li>All pointers will have this additional address. Even those which referring to the local objects. This is overhead. May be I should use 2 pointer classes: &quot;local&quot; and &quot;remote&quot;?</li>
<li>If program trying to dereference pointer, what should pointer do? Copy object from remote machine (I can do it using MPI-2 messaging system) and give a reference to it? But this copied object will not work, because it holds some regular pointers to its members. I need to make a copy of all its members, and members of their members,... the whole subtree need to be copied.</li>
<li>How the object should be modified? The local copy should be returned to the source machine and overwrite the original object?</li>
</ol>
<p>So, may be I need another idea? I can, for example, put all interface of my objects (which can be pointed by remote pointers) into a single function with fixed parameters and fixed return value. Then instead of dereferencing a pointer I can only call this function from the pointer. The pointer will then transfer this call (function arguments) to the target machine, call function on this machine, and return result back to the caller.</p>
<p>Now the problem is that the caller must pack all the data into the fixed arguments of such function, even if object is local. May be it is possible in C++ to pass various parameters with various types into a function, which will transfer them directly to the target interface function if object is local, or pack them and transfer to another machine, if object is remote?</p>
<p>Any advice is appreciated.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1867578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1867578</guid><dc:creator><![CDATA[SAn]]></dc:creator><pubDate>Thu, 11 Mar 2010 16:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer to point to object in another computer on Thu, 11 Mar 2010 16:25:50 GMT]]></title><description><![CDATA[<p>I want to do something like this:</p>
<p>Old way:</p>
<pre><code class="language-cpp">MyPointer p = this-&gt;GetNeighbor(nBottom);
p -&gt; DoSomething(10,20,30);
</code></pre>
<p>New way:</p>
<pre><code class="language-cpp">MyPointer p = this-&gt;GetNeighbor(nBottom);
p.Call(DoSomething,10,20,30));
</code></pre>
<p>Inside the MyPointer class:</p>
<pre><code class="language-cpp">class MyPointer
{
private:
  MyClass *p;
  int machineAdr;

public:
inline bool Call(func, arguments,...) //return true if it is known that func modifies its arguments
{
  if(machineAdr == ThisMachineAdr())
  {
    p-&gt;func(arguments,...);
    return FuncModifiesData( func ); 
  } else {
    data = PackData( func, arguments,... );
    bool dataModified = SendMessageToRemoteMachine( machineAddr, data );
    if( dataModified ) UnPackdata( data, arguments, ... );
  }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1867590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1867590</guid><dc:creator><![CDATA[SAn]]></dc:creator><pubDate>Thu, 11 Mar 2010 16:25:50 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer to point to object in another computer on Thu, 11 Mar 2010 16:26:21 GMT]]></title><description><![CDATA[<p>Maybe you're looking for RPC?<br />
<a href="http://en.wikipedia.org/wiki/Remote_procedure_call" rel="nofollow">http://en.wikipedia.org/wiki/Remote_procedure_call</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1867592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1867592</guid><dc:creator><![CDATA[blub* 0]]></dc:creator><pubDate>Thu, 11 Mar 2010 16:26:21 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer to point to object in another computer on Thu, 11 Mar 2010 16:32:46 GMT]]></title><description><![CDATA[<p>In fact, I have 2 questions:</p>
<ol>
<li>Do I really need the RPC in my program?</li>
<li>If I need it, what will be the best way to implement it over pointers using MPI in my C++ program (to minimize overhead and code change)?</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/1867596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1867596</guid><dc:creator><![CDATA[SAn]]></dc:creator><pubDate>Thu, 11 Mar 2010 16:32:46 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer to point to object in another computer on Thu, 11 Mar 2010 16:34:33 GMT]]></title><description><![CDATA[<p>Maybe google can help you, please look for CORBA or SOAP.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1867603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1867603</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 11 Mar 2010 16:34:33 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer to point to object in another computer on Thu, 11 Mar 2010 16:39:52 GMT]]></title><description><![CDATA[<p>I don't know if this is is practicable and how the performance might be, but here is an Idea:</p>
<p>Instead of having pointers that know about &quot;near&quot; or &quot;far&quot; objects (on the same or another machine, respectively), have proxies that have the same interface as the objects you want to share between machines. So you can use normal pointers that point to an real object on the same machine or to a proxy that stands for an object on another machine. The proxy is the only one to know the handle for the corresponding object on the &quot;other side&quot;, and if you call a method on the proxy it sends the correct message an waits for a return value, if necessary.<br />
I think it would be a serious overhead to copy the complete object, especially if you only need one of its variables.<br />
On the other hand, if in some cases you really need the whole data of the distant object, yout could do that on demand, i.e. only if the proxy really needs the data it requests the distant object to send the necessary data.<br />
In addition, as you have multiple processes you would need some type of synchronization between the objects and their copies/proxies anyways.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1867610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1867610</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 11 Mar 2010 16:39:52 GMT</pubDate></item></channel></rss>