[saga-rg] context problem

Pascal Kleijer k-pasukaru at ap.jp.nec.com
Thu Jul 20 19:06:46 CDT 2006


Hello Andre,

I will not come up with 3 counter arguments here. I will just show you 
that your first argument is flawed (or think it is).

We assume that the following is the example code:

   task t_1 = file.seek <saga::task::task> (100, saga::file::SeekSet);
   task t_2 = file.read <saga::task::task> (1, buf, &out);
   t_1.run ();
   t_1.wait ();
   t_2.run ();
   t_2.wait ();

In a traditional single machine implementation if we do a pure deep copy 
of the file object in the task then do the run-wait calls, yes it might 
be true that the read reads byte 1 and not byte 100. This depends on how 
the file handler is implemented internally, if we stick to a pure deep 
copy then it would mean the physical file is opened by two handles, thus 
the "seek" of t1 does not affect t2.

In our case we are dealing with a _remote_ file due to the very nature 
of SAGA. If we assume a WSRF implementation then the file object in our 
sample code is noting more internally then a End Point Reference (ERP) 
or similar depending on your implementation. Nothing is against having 
two full duplicates (due to the deep copy) of the EPR but still point to 
the same physical file with the same handle on the server site. When you 
do the run-wait we can assume an atomic call, which means the byte that 
is read is effectively # 100.

In a remote environment the real state of the object is not stored 
locally (client). So when you do a "seek" it happens on the remote 
object not locally. I would be a conception flaw if you did store the 
file internal pointer as well as other properties locally. My assumption 
is that you are mixing local and remote handling. Unless you want SAGA 
to handle within one object both aspects, which again is a conception 
flaw in my opinion.

I hope I was clear enough, otherwise I will need an extra run to the 
coffee machine. :p



>>>> In the case of non-OO languages it might be preferable to use by copy 
>>>> then by reference, this will however have an impact on the runtime but 
>>>> will avoid you a lot of troubles.
>>> I would assume that a non-OO implementations uses pointers
>>> to structures as object representations, or handles or such.
>>> Hence a copy would in fact represent a reference-copy, and
>>> the same semantics can easily be achieved.
>> Well no. The problem with non-OO languages and C++ is that you must 
>> explicitly garbage collect your objects (call a destroy). So if you just 
>> copy the pointer you cannot test if it has been destroyed unless you 
>> handle the pointer to the pointer and can test for a NULL (agrl in 
>> Fortran). So the idea is to make a full copy of the object state and use 
>> a locale copy within the thread. This might cause a big overhead and be 
>> rather tricky to implement, especially if object contains other objects. 
>> The recursion in copy might be either impossible, longish or very complex.
> 
> I disagree, and for two reasons even (that must be worth
> something :-)
> 
> For one, as I said in the thread earlier, I think that deep
> copy raises huge semantic problems:
> 
>   task t_1 = file.seek <saga::task::task> (100, saga::file::SeekSet);
>   task t_2 = file.read <saga::task::task> (1, buf, &out);
> 
>   t_1.run ();  
>   t_1.wait ();
> 
>   t_2.run ();  
>   t_2.wait ();
> 
> I, as a user, would assume that the read reads byte number
> 100.  But if we do a deep copy on task creation, the object
> state (e.g. the file pointer) gets _copied_.  So the seek
> operates on a different file pointer than the read, and the
> read in fact returns the first byte in the file.
> 
> That breaks a large number of use cases.
> 
> 
> 
> Secondly, you are right, C++ and C must handle destruction
> explicit - but that does not mean that you cannot copy
> references.  It just means that your implementaion needs to
> keep track of them!
> 
> Now, that might be difficult, but (a) there are many libs
> and tools helping with that and there also exist known
> practices on how to do that, and (b) SAGA is about
> ease-of-use, not ease-of-implementation.
> 
> 
> Hehe, now you need three counterarguments :-)  Lets see what
> you come up with :-D
> 
> Cheers, Andre.
> 
> 


-- 

Best regards,
Pascal Kleijer

----------------------------------------------------------------
   HPC Marketing Promotion Division, NEC Corporation
   1-10, Nisshin-cho, Fuchu, Tokyo, 183-8501, Japan.
   Tel: +81-(0)42/333.6389       Fax: +81-(0)42/333.6382
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4385 bytes
Desc: S/MIME Cryptographic Signature
Url : http://www.ogf.org/pipermail/saga-rg/attachments/20060721/7a9ba6c8/attachment-0003.bin 


More information about the saga-rg mailing list