]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
[EDF26936] : End of the 2GB limit.
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 10 Feb 2023 16:06:55 +0000 (17:06 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 10 Feb 2023 16:06:55 +0000 (17:06 +0100)
idl/SALOME_Comm.idl
idl/SALOME_PyNode.idl
src/Communication/ReceiverFactory.cxx
src/Communication/ReceiverFactory.hxx
src/Container/SALOME_PyNode.py

index bf9f782b8c26d238aa25c273dcf10c29f9aa05e0..911629531057253aabbd0e8be5f05ab42b401b3c 100644 (file)
@@ -40,6 +40,8 @@ module SALOME {
   
   typedef sequence<long> vectorOfLong;
   
+  typedef sequence<octet> vectorOfByte;
+  
   interface MultiCommClass {
     void setProtocol(in TypeOfCommunication typ);
   };
@@ -132,6 +134,12 @@ module SALOME {
     long getSizeOfColumn();
     void release();
   };
+
+  interface SenderByte
+  {
+    unsigned long getSize();
+    vectorOfByte sendPart(in unsigned long n1,in unsigned long n2);
+  };
 };
 
 #endif
index 23a2b47094c378a722be28572cf31cf4048af1e7..58e9d3898fa22f909d55db0660a6e42172246729 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "SALOME_GenericObj.idl"
 #include "SALOME_Exception.idl"
+#include "SALOME_Comm.idl"
 
 /*! \file SALOME_PyNode.idl \brief interface for remote python execution
 */
@@ -95,7 +96,7 @@ module Engines
 
     /*! \brief second and last part of execute method. This split is to reduce the memory peak.
     */
-    pickledArgs executeSecond(in listofstring outargsname) raises (SALOME::SALOME_Exception);
+    SALOME::SenderByte executeSecond(in listofstring outargsname) raises (SALOME::SALOME_Exception);
 
     pickledArgs getValueOfVarInContext(in string varName) raises (SALOME::SALOME_Exception);
 
index 5f354df8d5ac750d1c6e2b33172e2ba5319c5a9f..44ff3a0cdb10d5de8add8f9091aac4ff127dcf61 100644 (file)
@@ -186,3 +186,43 @@ int *ReceiverFactory::getValueOneShot(SALOME::SenderInt_ptr sender,long &size)
     }
 }
 
+SeqByteReceiver::SeqByteReceiver(SALOME::SenderByte_ptr sender):_obj(SALOME::SenderByte::_duplicate(sender))
+{
+}
+
+char *SeqByteReceiver::data(unsigned long& size)
+{
+  size = _obj->getSize();
+  if(size <= CHUNK_SIZE)
+  {
+    this->fetchOneShot( size );
+    return reinterpret_cast<char *>(_data_one_shot->get_buffer());
+  }
+  else
+  {
+    this->fetchByChunks( size );
+    return _data_for_split_case.get();
+  }
+}
+
+void SeqByteReceiver::fetchOneShot(unsigned long size)
+{
+  _data_one_shot.reset( _obj->sendPart(0,size) );
+}
+
+void SeqByteReceiver::fetchByChunks(unsigned long size)
+{
+  _data_for_split_case.reset( new char[size] );
+  char *destination = _data_for_split_case.get();
+  constexpr unsigned long EFF_CHUNK_SIZE = CHUNK_SIZE / 8;
+  unsigned long iStart = 0;
+  unsigned long iEnd = EFF_CHUNK_SIZE;
+  while( iStart!=iEnd && iEnd <= size )
+  {
+    std::unique_ptr<SALOME::vectorOfByte> part( _obj->sendPart(iStart,iEnd) );
+    const unsigned char *partC = part->get_buffer();
+    std::copy(partC,partC+(iEnd-iStart),destination+iStart);
+    iStart = iEnd; iEnd = std::min(iStart + EFF_CHUNK_SIZE,size);
+  }
+}
+
index 03c8b873e441bb6a26d67975313f868deca4901a..3d61b262ff75da9bf695391c14e12cc18d0b0b37 100644 (file)
@@ -43,5 +43,22 @@ private:
   static int *getValueOneShot(SALOME::SenderInt_ptr sender,long &size);
 };
 
+#include <memory>
+
+class COMMUNICATION_EXPORT SeqByteReceiver
+{
+public:
+  SeqByteReceiver(SALOME::SenderByte_ptr sender);
+  char *data(unsigned long& size);
+private:
+  void fetchOneShot(unsigned long size);
+  void fetchByChunks(unsigned long size);
+private:
+  static constexpr unsigned long CHUNK_SIZE = 2000000000;
+  std::unique_ptr<char[]> _data_for_split_case;
+  std::unique_ptr<SALOME::vectorOfByte> _data_one_shot;
+  SALOME::SenderByte_var _obj;
+};
+
 #endif
 
index 74bc948ee046553a2f03bc63f553e4441d787553..1a0b3eb0b7e0f56bdabbd7f73330a0db1122aa08 100644 (file)
@@ -103,6 +103,16 @@ class PyNode_i (Engines__POA.PyNode,Generic):
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyNode: %s, function: %s" % (self.nodeName,funcName),0))
 
+class SenderByte_i(SALOME__POA.SenderByte):
+  def __init__(self,bytesToSend):
+    self.bytesToSend = bytesToSend
+
+  def getSize(self):
+    return len(self.bytesToSend)
+
+  def sendPart(self,n1,n2):
+    return self.bytesToSend[n1:n2]
+
 class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
   """The implementation of the PyScriptNode CORBA IDL that executes a script"""
   def __init__(self, nodeName,code,poa,my_container):
@@ -183,7 +193,10 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
           raise KeyError("There is no variable %s in context" % arg)
         argsout.append(self.context[arg])
       argsout=pickle.dumps(tuple(argsout),-1)
-      return argsout
+      ret = SenderByte_i( argsout )
+      id_o = self.poa.activate_object(ret)
+      retObj = self.poa.id_to_reference(id_o)
+      return retObj._narrow( SALOME.SenderByte )
     except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)