portage to windows of MPI module, add some errors messages 84/12484/2
Antoine ELIAS [Wed, 11 Sep 2013 09:19:31 +0000 (11:19 +0200)]
Change-Id: I2daeb223ba20b3ca22a65a9532ff7e8a33d94630

31 files changed:
scilab/Scilab.sln
scilab/etc/modules.xml.vc
scilab/libs/.gitignore
scilab/modules/api_scilab/includes/api_scilab.h
scilab/modules/core/src/c/callinterf.c
scilab/modules/mpi/examples/foo.sci
scilab/modules/mpi/includes/dynlib_mpi.h [new file with mode: 0644]
scilab/modules/mpi/includes/gw_mpi.h
scilab/modules/mpi/mpi.vcxproj [new file with mode: 0644]
scilab/modules/mpi/mpi.vcxproj.filters [new file with mode: 0644]
scilab/modules/mpi/sci_gateway/c/gw_mpi.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_bcast.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_comm_rank.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_comm_size.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_finalize.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_get_processor_name.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_init.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_irecv.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_isend.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_recv.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_send.c
scilab/modules/mpi/sci_gateway/c/sci_mpi_wait.c
scilab/modules/mpi/sci_gateway/mpi_gateway.xml
scilab/modules/mpi/src/c/DllmainMpi.c [new file with mode: 0644]
scilab/modules/mpi/src/c/deserialization.c
scilab/modules/mpi/src/c/deserialization.h
scilab/modules/mpi/src/c/mpi.rc [new file with mode: 0644]
scilab/modules/mpi/src/c/pre_send_recv_metadata.c
scilab/modules/mpi/src/c/sci_mpi.h
scilab/modules/mpi/src/c/serialization.c
scilab/modules/mpi/src/c/serialization.h

index 76c3b69..4c1a3b1 100644 (file)
@@ -514,6 +514,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scicos-cli", "modules\scico
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scicos_blocks-cli", "modules\scicos_blocks\src\c\cli\scicos_blocks-cli.vcxproj", "{424A5578-BA28-435F-8313-8D85886A3539}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpi", "modules\mpi\mpi.vcxproj", "{5E726409-247A-464A-A994-6E6A7A02A981}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -1598,6 +1600,14 @@ Global
                {424A5578-BA28-435F-8313-8D85886A3539}.Release|Win32.Build.0 = Release|Win32
                {424A5578-BA28-435F-8313-8D85886A3539}.Release|x64.ActiveCfg = Release|x64
                {424A5578-BA28-435F-8313-8D85886A3539}.Release|x64.Build.0 = Release|x64
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Debug|Win32.ActiveCfg = Debug|Win32
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Debug|Win32.Build.0 = Debug|Win32
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Debug|x64.ActiveCfg = Debug|x64
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Debug|x64.Build.0 = Debug|x64
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Release|Win32.ActiveCfg = Release|Win32
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Release|Win32.Build.0 = Release|Win32
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Release|x64.ActiveCfg = Release|x64
+               {5E726409-247A-464A-A994-6E6A7A02A981}.Release|x64.Build.0 = Release|x64
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index d57405d..8b9c161 100644 (file)
@@ -92,5 +92,6 @@
 <module name="xml" activate="yes"/>
 <module name="external_objects" activate="yes"/>
 <module name="external_objects_java" activate="yes"/>
+<module name="mpi" activate="yes"/>
 <!-- comments -->
 </modules>
index c39e912..7dca4ee 100644 (file)
@@ -16,3 +16,4 @@ Eigen
 *.lib
 Eigen
 curl
+openmpi
\ No newline at end of file
index 9c49045..02ca3c0 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __VARIABLE_API__
 #define __VARIABLE_API__
 
+
 /*
 * 1 : First version
 * 2 : Shortcut functions added
index fa39576..9b6665d 100644 (file)
@@ -34,7 +34,7 @@ jmp_buf jmp_env;
  ** Watch out the positions are crutial !!!
  ** @TODO : Make this less crappy...
  **/
-#define INTERFACES_MAX 72
+#define INTERFACES_MAX 73
 static OpTab Interfaces[INTERFACES_MAX] =
 {
     /* 01  */ {gw_user}, /* free position may be used */
index 6276d4b..875197c 100644 (file)
@@ -1,16 +1,15 @@
-num = mpi_comm_rank()
-
-N =  mpi_comm_size()
-
-src  = modulo(num+N-1, N)
-
-dest = modulo(num+1, N)
-
-
-if ((modulo(num,2) == 0)) then 
-       mpi_send(num,dest,1001)
-       res = mpi_recv(src,1001)
-else 
-       res = mpi_recv(src,1001)
-       mpi_send(num,dest,1001)
+MPI_Init();
+rnk = MPI_Comm_rank()
+sizeNodes =    MPI_Comm_size();
+SLV = rnk;
+Master = ~ SLV;
+
+if Master then
+    disp("Master");
+    MPI_Send(rand(10,10), 1);
+else
+    val = MPI_Recv(0, 0);
+    disp(val, rnk)
 end
+
+MPI_Finalize();
diff --git a/scilab/modules/mpi/includes/dynlib_mpi.h b/scilab/modules/mpi/includes/dynlib_mpi.h
new file mode 100644 (file)
index 0000000..af0bbca
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) Scilab Enterprises - 2013 - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+*
+*/
+
+/*--------------------------------------------------------------------------*/
+#ifndef __DYNLIB_MPI_H__
+#define __DYNLIB_MPI_H__
+
+#ifdef _MSC_VER
+#ifdef MPI_EXPORTS
+#define MPI_IMPEXP __declspec(dllexport)
+#else
+#define MPI_IMPEXP __declspec(dllimport)
+#endif
+#else
+#define MPI_IMPEXP
+#endif
+
+#endif /* __DYNLIB_MPI_H__ */
+/*--------------------------------------------------------------------------*/
index 82fbe28..5379861 100644 (file)
 #ifndef __GW_MPI__
 #define __GW_MPI__
 
-#ifdef _MSC_VER
-#include <windows.h>
-#include <stdio.h>
-#endif
+#include "dynlib_mpi.h"
 
-#include <string.h>
-#include "machine.h"
-#include "api_scilab.h"
-#include "stack-c.h"
-
-int gw_mpi(void);
+MPI_IMPEXP int gw_mpi(void);
 
 typedef int (*MPI_Interf) (char *fname, unsigned long l);
-
-typedef struct table_struct
-{
-    MPI_Interf f;  /** function **/
-    char *name;    /** its name **/
-} MPITable;
-
-// Declaration of all the profile function declared and
-// used in sci_gateway
+/*--------------------------------------------------------------------------*/
+/* interface for the previous function Table */
+/*--------------------------------------------------------------------------*/
 int sci_mpi_init(char *fname, unsigned long fname_len);
 int sci_mpi_finalize(char *fname, unsigned long fname_len);
 int sci_mpi_comm_size(char *fname, unsigned long fname_len);
@@ -46,11 +32,4 @@ int sci_mpi_bcast(char *fname, unsigned long fname_len);
 int sci_mpi_irecv(char *fname, unsigned long fname_len);
 int sci_mpi_isend(char *fname, unsigned long fname_len);
 int sci_mpi_wait(char *fname, unsigned long fname_len);
-
-/*
-int intsmpi_comm_size (char *fname,unsigned long fname_len));
-
-int intsmpi_irecv (char *fname,unsigned long fname_len));
-int intsmpi_isend (char *fname,unsigned long fname_len));
-*/
 #endif /*  __GW_MPI__ */
diff --git a/scilab/modules/mpi/mpi.vcxproj b/scilab/modules/mpi/mpi.vcxproj
new file mode 100644 (file)
index 0000000..14ef17e
--- /dev/null
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{5E726409-247A-464A-A994-6E6A7A02A981}</ProjectGuid>
+    <RootNamespace>time</RootNamespace>
+    <Keyword>Win32Proj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <WholeProgramOptimization>false</WholeProgramOptimization>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <WholeProgramOptimization>false</WholeProgramOptimization>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>../../libs/openmpi/include;includes;src/c;../api_scilab/includes;../core/includes;../output_stream/includes;../localization/includes;../../libs/intl</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>FORDLL;_DEBUG;_WINDOWS;_USRDLL;MPI_EXPORTS;_CRT_SECURE_NO_DEPRECATE;OMPI_IMPORTS;OPAL_IMPORTS;ORTE_IMPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <PreLinkEvent>
+    </PreLinkEvent>
+    <Link>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+      <ModuleDefinitionFile>
+      </ModuleDefinitionFile>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+      <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+      <TargetMachine>MachineX86</TargetMachine>
+      <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>../../libs/openmpi/include;includes;src/c;../api_scilab/includes;../core/includes;../output_stream/includes;../localization/includes;../../libs/intl</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>FORDLL;_DEBUG;_WINDOWS;_USRDLL;MPI_EXPORTS;_CRT_SECURE_NO_DEPRECATE;OMPI_IMPORTS;OPAL_IMPORTS;ORTE_IMPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+      <ModuleDefinitionFile>
+      </ModuleDefinitionFile>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+      <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+      <TargetMachine>MachineX64</TargetMachine>
+      <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+      <AdditionalIncludeDirectories>../../libs/openmpi/include;includes;src/c;../api_scilab/includes;../core/includes;../output_stream/includes;../localization/includes;../../libs/intl</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>FORDLL;NDEBUG;_WINDOWS;_USRDLL;MPI_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <WarningLevel>Level3</WarningLevel>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+      <ModuleDefinitionFile>
+      </ModuleDefinitionFile>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+      <TargetMachine>MachineX86</TargetMachine>
+      <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+      <AdditionalIncludeDirectories>../../libs/openmpi/include;includes;src/c;../api_scilab/includes;../core/includes;../output_stream/includes;../localization/includes;../../libs/intl</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>FORDLL;NDEBUG;_WINDOWS;_USRDLL;MPI_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <WarningLevel>Level3</WarningLevel>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+      <ModuleDefinitionFile>
+      </ModuleDefinitionFile>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+      <TargetMachine>MachineX64</TargetMachine>
+      <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="includes\dynlib_mpi.h" />
+    <ClInclude Include="includes\gw_mpi.h" />
+    <ClInclude Include="src\c\deserialization.h" />
+    <ClInclude Include="src\c\sci_mpi.h" />
+    <ClInclude Include="src\c\serialization.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="sci_gateway\c\gw_mpi.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_bcast.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_comm_rank.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_comm_size.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_finalize.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_get_processor_name.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_init.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_irecv.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_isend.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_recv.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_send.c" />
+    <ClCompile Include="sci_gateway\c\sci_mpi_wait.c" />
+    <ClCompile Include="src\c\deserialization.c" />
+    <ClCompile Include="src\c\DllmainMpi.c" />
+    <ClCompile Include="src\c\serialization.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="src\c\mpi.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\api_scilab\api_scilab.vcxproj">
+      <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
+    </ProjectReference>
+    <ProjectReference Include="..\core\src\c\core.vcxproj">
+      <Project>{c6e2bc17-34d8-46e4-85f3-6293cb21adcd}</Project>
+    </ProjectReference>
+    <ProjectReference Include="..\output_stream\src\c\output_stream.vcxproj">
+      <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/scilab/modules/mpi/mpi.vcxproj.filters b/scilab/modules/mpi/mpi.vcxproj.filters
new file mode 100644 (file)
index 0000000..a89f66d
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{6dbf7529-8fc2-429c-b172-1a4705e406d6}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{99e7e73f-3a6b-4e36-b4e5-403fa9ef3671}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{513ed79d-e6e4-428a-ba65-070e90b9221f}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="src\c\mpi.rc">
+      <Filter>Resource Files</Filter>
+    </ResourceCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="includes\gw_mpi.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\c\deserialization.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\c\sci_mpi.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\c\serialization.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="includes\dynlib_mpi.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="src\c\deserialization.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\c\serialization.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\gw_mpi.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_bcast.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_comm_rank.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_comm_size.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_finalize.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_get_processor_name.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_init.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_irecv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_isend.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_recv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_send.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_mpi_wait.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\c\DllmainMpi.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>
\ No newline at end of file
index c8c13d5..1ad65ce 100644 (file)
  *
  */
 #include "gw_mpi.h"
-#ifdef _MSC_VER
-#include <Windows.h>
-#include "ExceptionMessage.h"
-#endif
-#include "machine.h"
+#include "api_scilab.h"
+#include "MALLOC.h"
+#include "callFunctionFromGateway.h"
 /*-----------------------------------------------------------------------------------*/
-static MPITable Tab[] =
+static gw_generic_table Tab[] =
 {
     {sci_mpi_init, "MPI_Init"},
     {sci_mpi_finalize, "MPI_Finalize"},
@@ -31,39 +29,18 @@ static MPITable Tab[] =
     {sci_mpi_wait, "MPI_Wait"}
 
 };
-
-/*static MPITable Tab[]=
-{
-       {intsmpi_send,"mpi_send"},
-       {intsmpi_recv,"mpi_recv"},
-       {intsmpi_isend,"mpi_isend"},
-       {intsmpi_irecv,"mpi_irecv"},
-       {intsmpi_init,"mpi_init"},
-       {intsmpi_finalize,"mpi_finalize"},
-       {intsmpi_comm_rank,"mpi_comm_rank"},
-       {intsmpi_comm_size,"mpi_comm_size"}
-};*/
 /*-----------------------------------------------------------------------------------*/
 int gw_mpi(void)
 {
     Rhs = Max(0, Rhs);
 
-#ifdef _MSC_VER
-#ifndef _DEBUG
-    _try
+    if (pvApiCtx == NULL)
     {
-        (*(Tab[Fin - 1].f)) (Tab[Fin - 1].name, strlen(Tab[Fin - 1].name));
+        pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
     }
-    _except(EXCEPTION_EXECUTE_HANDLER)
-    {
-        ExceptionMessage(GetExceptionCode(), Tab[Fin - 1].name);
-    }
-#else
-    (*(Tab[Fin - 1].f)) (Tab[Fin - 1].name, strlen(Tab[Fin - 1].name));
-#endif
-#else
-    (*(Tab[Fin - 1].f)) (Tab[Fin - 1].name, strlen(Tab[Fin - 1].name));
-#endif
+
+    pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
+    callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
     return 0;
 }
 
index f85a2c7..ffd7c2e 100644 (file)
@@ -9,9 +9,10 @@
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
+
+#include "api_scilab.h"
 #include <stdio.h>
 #include <mpi.h>
-#include "api_scilab.h"
 #include "gw_mpi.h"
 #include "Scierror.h"
 #include "MALLOC.h"
@@ -31,6 +32,8 @@ int sci_mpi_bcast(char *fname, unsigned long fname_len)
     int iBufferSize = 0;
     double rootID = 0;
 
+    int length = 0;
+
     CheckInputArgument(pvApiCtx, 2, 2);
     CheckOutputArgument(pvApiCtx, 1, 1);
 
@@ -38,106 +41,62 @@ int sci_mpi_bcast(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr2, &rootID))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 1);
+        return 0;
     }
 
     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
         return 0;
     }
 
-    sciErr = getVarType(pvApiCtx, piAddr, &iType);
-    if (sciErr.iErr)
+    iRet = serialize_to_mpi(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
+    if (iRet)
     {
-        printError(&sciErr, 0);
+        Scierror(999, _("Unable to serialize data\n"));
         return 0;
     }
 
-    switch (iType)
-    {
-        case sci_matrix:
-            iRet = serialize_double(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_strings:
-            iRet = serialize_string(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = serialize_boolean(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = serialize_sparse(pvApiCtx, piAddr, &piBuffer, &iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = serialize_sparse(pvApiCtx, piAddr, &piBuffer, &iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = serialize_int(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        default:
-            Scierror(999, _("%s: Wrong values for input argument #%d: Unsupported '%s' type.\n"), fname, iType);
-            break;
-    }
-
-    if (iRet)
+    /* First, send the size of the data as broadcast */
+    iRet = MPI_Bcast(&iBufferSize, 1, MPI_INT, (int)rootID, MPI_COMM_WORLD);
+    if (iRet != MPI_SUCCESS)
     {
-        printf("pas reussi a seraliser\n");
+        char error_string[MPI_MAX_ERROR_STRING];
+        int length_of_error_string = 0;
+        MPI_Error_string(iRet, error_string, &length_of_error_string);
+        Scierror(999, _("%s: Could not broadcast the variable to the node %d: %s\n"), fname, rootID, error_string);
+        return 0;
     }
-    int rank, length;
-    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
-    /* First, send the size of the data as broadcast */
-    iRet = MPI_Bcast(&iBufferSize, 1, MPI_INT, rootID, MPI_COMM_WORLD);
 
     /* Second, restore the data with the right size */
-    iRet = MPI_Bcast(piBuffer, iBufferSize, MPI_INT, rootID, MPI_COMM_WORLD);
-
+    iRet = MPI_Bcast(piBuffer, iBufferSize, MPI_INT, (int)rootID, MPI_COMM_WORLD);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
-        int length_of_error_string;
-
-        printf("ICI \n");
-        fflush(NULL);
+        int length_of_error_string = 0;
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: Could not broadcast the variable to the node %d: %s\n", fname, rootID, error_string);
-        return 1;
+        Scierror(999, _("%s: Could not broadcast the variable to the node %d: %s\n"), fname, rootID, error_string);
+        return 0;
     }
 
-    switch (piBuffer[0])
+    iRet = deserialize_from_mpi(pvApiCtx, piBuffer, iBufferSize);
+    FREE(piBuffer);
+    if (iRet)
     {
-        case sci_matrix:
-            iRet = deserialize_double(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_strings:
-            iRet = deserialize_string(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = deserialize_boolean(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = deserialize_int(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        default:
-            return 1;
-            break;
+        Scierror(999, _("%s: Unable to deserialize data !\n"), fname);
+        return 0;
     }
 
-    //    free(piBuffer);
-
-    AssignOutputVariable(pvApiCtx, 1) = 1;
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index fbcfab6..aaaf944 100644 (file)
@@ -11,6 +11,9 @@
  */
 #include "gw_mpi.h"
 #include "sci_mpi.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "api_scilab.h"
 
 /**
  * SCILAB function : mpi_comm_rank, fin = 7
 
 int sci_mpi_comm_rank (char *fname, unsigned long fname_len)
 {
-    int comm_rank;
-    int n1 = 1, m1 = 1, l1 = 0;
+    int comm_rank = 0;
+
     CheckInputArgument(pvApiCtx, 0, 0); // Check the parameters of the function ... Here 0
     CheckOutputArgument(pvApiCtx, 1, 1); // The output of the function (1 parameter)
+
     MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
 
-    CreateVar(1, "d", &m1, &n1 , &l1); // Create the space in the stack for comm_rank
-    *stk(l1) = (double)comm_rank; // Copy comm_size into the stack
+    if (createScalarDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, (double)comm_rank))
+    {
+        Scierror(999, _("%s: Unable to create variable.\n"), fname);
+        return 0;
+    }
 
-    AssignOutputVariable(pvApiCtx, 1) = 1;
-    C2F(putlhsvar)();
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    ReturnArguments(pvApiCtx);
     return 0;
 }
 
index ab05850..e1d0e85 100644 (file)
@@ -16,6 +16,7 @@
 #include "stack-c.h"
 #include "Scierror.h"
 #include "localization.h"
+#include "MALLOC.h"
 
 /**
  * SCILAB function : mpi_comm_size, fin = 3
  */
 int sci_mpi_comm_size(char *fname, unsigned long fname_len)
 {
+    SciErr sciErr;
     int comm_size;
-    MPI_Comm comm = NULL;
+    MPI_Comm comm = MPI_COMM_WORLD;
     int *piAddr = NULL;
-    int iRows = 1;
-    int iCols = 1;
-    int iRows2 = 1;
-    int iCols2 = 1;
-    double *pdblReal = NULL;
+    double dblReal = 0;
 
     CheckInputArgument(pvApiCtx, 0, 1);            // Check the parameters of the function ... Here 0 or 1
     CheckOutputArgument(pvApiCtx, 1, 1);            // The output of the function (1 parameter)
-    if (Rhs == 1)
-    {
-        int typevar;
-
-        getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
 
-        getVarType(pvApiCtx, piAddr, &typevar);
-        if (typevar == sci_matrix)
+    if (nbInputArgument(pvApiCtx) == 1)
+    {
+        sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+        if (sciErr.iErr)
         {
-            getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal);
-            // TODO manage scierr
-            comm = (MPI_Comm) (int)pdblReal;
+            printError(&sciErr, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+            return 0;
         }
-        else
+
+        if (getScalarDouble(pvApiCtx, piAddr, &dblReal))
         {
-            // TODO: update error message
-            Scierror(999, _("%s: Wrong type for input argument #%d: Scalar expected.\n"), fname, 1);
+            Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 1);
+            return 0;
         }
-    }
-    else
-    {
-        comm = MPI_COMM_WORLD;
-    }
-    MPI_Comm_size(comm, &comm_size);
-
-    double *pdblReal1 = (double *)malloc(sizeof(double) * iRows2 * iCols2);
 
-    pdblReal1[0] = (double)comm_size;
-
-    SciErr iRet = createMatrixOfDouble(pvApiCtx, Rhs + 1, iRows2, iCols2, pdblReal1);
+        comm = (MPI_Comm)(int)dblReal;
+    }
 
-    if (iRet.iErr)
+    MPI_Comm_size(comm, &comm_size);
+    if (createScalarDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, (double)comm_size))
     {
-        // TODO: update error message
-        Scierror(999, "error in the creation of the variable");
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
     }
-    free(pdblReal1);
-    //  CreateVar(1, "d", &m1, &n1 ,&l1); // Create the space in the stack for comm_size
-    //  *stk(l1)=(double)comm_size; // Copy comm_size into the stack
 
-    AssignOutputVariable(pvApiCtx, 1) = Rhs + 1;
-    C2F(putlhsvar) ();
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    ReturnArguments(pvApiCtx);
     return 0;
 }
index 13a8610..0200970 100644 (file)
@@ -14,6 +14,9 @@
 #include "gw_mpi.h"
 #include "sci_mpi.h"
 #include "Scierror.h"
+#include "localization.h"
+#include "api_scilab.h"
+#include "MALLOC.h"
 
 /******************************************
  * SCILAB function : mpi_finalize, fin = 2
 
 static void mpi_finalize_internal()
 {
-    free(listRequestPointer);
-    free(listRequestPointerSize);
-    free(request);
+    FREE(listRequestPointer);
+    FREE(listRequestPointerSize);
+    FREE(request);
 }
 
 int sci_mpi_finalize(char *fname, unsigned long fname_len)
 {
-    int iRet;
+    int iRet = 0;
     CheckInputArgument(pvApiCtx, 0, 0);
     CheckOutputArgument(pvApiCtx, 1, 1);
     mpi_finalize_internal();
     iRet = MPI_Finalize();
     if (iRet != MPI_SUCCESS)
     {
-        printf("ici %d\n", iRet);
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: Could not finalize the MPI instance: %s\n", fname, error_string);
-        return 1;
+        Scierror(999, _("%s: Could not finalize the MPI instance: %s\n"), fname, error_string);
+        return 0;
     }
 
     // TODO: catch les erreurs
     AssignOutputVariable(pvApiCtx, 1) = 0;
-    C2F(putlhsvar) ();
-
+    ReturnArguments(pvApiCtx);
     return 0;
 
 }
index 4d44db8..789aa2e 100644 (file)
@@ -23,7 +23,7 @@
  */
 int sci_mpi_get_processor_name(char *fname, unsigned long fname_len)
 {
-    MPI_Comm comm = NULL;
+    MPI_Comm comm = 0;
     int *piAddr = NULL;
     int iRows = 1;
     int iCols = 1;
@@ -31,21 +31,28 @@ int sci_mpi_get_processor_name(char *fname, unsigned long fname_len)
     int iCols2 = 1;
     int iSizeProcessorName;
     char processorName[MPI_MAX_PROCESSOR_NAME];
+    int iRet = 0;
 
     CheckInputArgument(pvApiCtx, 0, 0);
     CheckOutputArgument(pvApiCtx, 1, 1);            // The output of the function (1 parameter)
 
-    MPI_Get_processor_name(processorName, &iSizeProcessorName);
-
-    int iRet = createSingleString(pvApiCtx, Rhs + 1, processorName);
+    iRet = MPI_Get_processor_name(processorName, &iSizeProcessorName);
+    if (iRet != MPI_SUCCESS)
+    {
+        char error_string[MPI_MAX_ERROR_STRING];
+        int length_of_error_string;
+        MPI_Error_string(iRet, error_string, &length_of_error_string);
+        Scierror(999, _("%s: Could not get processor name: %s\n"), fname, error_string);
+        return 0;
+    }
 
-    if (iRet)
+    if (createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, processorName))
     {
-        // TODO: update error message
-        Scierror(999, "error in the creation of the variable");
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
     }
 
-    AssignOutputVariable(pvApiCtx, 1) = Rhs + 1;
-    C2F(putlhsvar) ();
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    ReturnArguments(pvApiCtx);
     return 0;
 }
index 9464971..35e3c13 100644 (file)
@@ -14,6 +14,7 @@
 #include "stack-c.h"
 #include "gw_mpi.h"
 #include "sci_mpi.h"
+#include "MALLOC.h"
 
 /**
  * SCILAB function : mpi_init, fin = 1
@@ -42,15 +43,14 @@ static void mpi_init_internal()
         return;
     }
 
-    request = (MPI_Request *)calloc(REQUEST_MAXSIZE, sizeof(MPI_Request));
-    listRequestPointer = (int)calloc(REQUEST_MAXSIZE, sizeof(int));
-    listRequestPointerSize = (int)calloc(REQUEST_MAXSIZE, sizeof(int));
+    request = (MPI_Request *)MALLOC(REQUEST_MAXSIZE * sizeof(MPI_Request));
+    listRequestPointer = (int**)MALLOC(REQUEST_MAXSIZE * sizeof(int*));
+    listRequestPointerSize = (int*)MALLOC(REQUEST_MAXSIZE * sizeof(int));
     for (i = 0; i < REQUEST_MAXSIZE; i++)
     {
-        request[i] = MPI_REQUEST_NULL;
+        request[i] = 0;
         listRequestPointer[i] = NULL;
-        listRequestPointerSize[i] = NULL;
-        i++;
+        listRequestPointerSize[i] = 0;
     }
 
     mpi_initialized = TRUE;
@@ -70,8 +70,6 @@ int sci_mpi_init(char *fname, unsigned long fname_len)
         /* MPI Not yet initialized */
         MPI_Init(NULL, NULL);
         MPI_Comm_create_errhandler(MPIErrHandler, &errhdl);
-
-        printf("MPI_INIT : init done\n");
     }
     AssignOutputVariable(pvApiCtx, 1) = 0;
     ReturnArguments(pvApiCtx);
index 11d7718..9dfa292 100644 (file)
@@ -31,8 +31,8 @@ int sci_mpi_irecv(char *fname, unsigned long fname_len)
     int *piAddr3 = NULL;
     double Tag = 0;
     double Rank = 0;
-    double RequestID = 0;
-
+    int iRequestID = 0;
+    double dblRequestID = 0;
     MPI_Status status;
 
     CheckInputArgument(pvApiCtx, 3, 3);
@@ -43,12 +43,14 @@ int sci_mpi_irecv(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr1, &Rank))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 1);
+        return 0;
     }
 
     //Tag
@@ -56,128 +58,81 @@ int sci_mpi_irecv(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr2, &Tag))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 2);
+        return 0;
     }
 
 
     // Request
-
     sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
         return 0;
     }
 
-    if (getScalarDouble(pvApiCtx, piAddr3, &RequestID))
+    if (getScalarDouble(pvApiCtx, piAddr3, &dblRequestID))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 3);
+        return 0;
     }
 
-    if (RequestID < 0)
+    iRequestID = (int)dblRequestID;
+    if (iRequestID < 0)
     {
         Scierror(999, _("%s: Wrong values for input argument #%d: Positive value expected.\n"), fname, 3);
         return 0;
     }
-    /*
-        iRet = mpi_my_recv(&piBuffer, &iBufferSize);
-        if(iRet)
-        {
-            return 1;
-        }
-    */
-
-    iRet = MPI_Probe(Rank, Tag, MPI_COMM_WORLD, &status);
+
+    iRet = MPI_Probe((int)Rank, (int)Tag, MPI_COMM_WORLD, &status);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: MPI_Probe failed. Rank %d / Tag %d: %s\n", fname, Rank, Tag, error_string);
-        return 1;
+        Scierror(999, _("%s: MPI_Probe failed. Rank %d / Tag %d: %s\n"), fname, Rank, Tag, error_string);
+        return 0;
     }
 
-    if (MPI_Get_count(&status, MPI_INT, &iBufferSize) != MPI_SUCCESS)
+    iRet = MPI_Get_count(&status, MPI_INT, &iBufferSize);
+    if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: MPI_Get_count failed. Rank %d / Tag %d: %s\n", fname, Rank, Tag, error_string);
-        return 1;
+        Scierror(999, _("%s: MPI_Get_count failed. Rank %d / Tag %d: %s\n"), fname, Rank, Tag, error_string);
+        return 0;
     }
 
     piBuffer = (int *)MALLOC(sizeof(int) * iBufferSize);
     if (piBuffer == NULL)
     {
         Scierror(999, "%s: Could not create the received variable.\n", fname);
-        return 1;
+        return 0;
     }
 
-    /* Recuperer le nom de la variable et la mettre dans listRequestVarName */
-    /* char *varName=(char*)malloc(1024*sizeof(char)); */
-    /* getVarNameFromPosition(pvApiCtx, 1, varName); */
-    /* printf("varName %s\n", varName); */
-
-    //    listRequestPointer[(int)RequestID]=(char*)malloc(1024*sizeof(char));
-    //    getVarNameFromPosition(pvApiCtx, 1, listRequestPointer[(int)RequestID]);
-    //    printf("varName %s\n", listRequestPointer[(int)RequestID]);
-
-
-    iRet = MPI_Irecv(piBuffer, iBufferSize, MPI_INT, Rank, Tag, MPI_COMM_WORLD, &request[(int)RequestID]);
-
+    iRet = MPI_Irecv(piBuffer, iBufferSize, MPI_INT, (int)Rank, (int)Tag, MPI_COMM_WORLD, &request[iRequestID]);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: MPI_Irecv failed. Rank %d / Tag %d: %s\n", fname, Rank, Tag, error_string);
-
-        return 1;
+        Scierror(999, _("%s: MPI_Irecv failed. Rank %d / Tag %d: %s\n"), fname, Rank, Tag, error_string);
+        return 0;
     }
 
     /* Store the pointer piBuffer */
-    listRequestPointer[(int)RequestID] = piBuffer;
-    listRequestPointerSize[(int)RequestID] = iBufferSize;
-    /*
-        switch (piBuffer[0])
-        {
-        case sci_matrix:
-            iRet = deserialize_double(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_strings:
-            iRet = deserialize_string(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = deserialize_boolean(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = deserialize_int(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        default:
-            return 1;
-            break;
-        }
-
-        if (iRet)
-        {
-            return 1;
-        }
-    */
-    AssignOutputVariable(pvApiCtx, 1) = 1;
+    listRequestPointer[iRequestID] = piBuffer;
+    listRequestPointerSize[iRequestID] = iBufferSize;
+
+    AssignOutputVariable(pvApiCtx, 1) = 0;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index 2e8588a..948ef5c 100644 (file)
@@ -34,7 +34,8 @@ int sci_mpi_isend(char *fname, unsigned long fname_len)
     int *piBuffer = NULL;
     int iBufferSize = 0;
     double NodeID = 0;
-    double RequestID = 0;
+    int iRequestID = 0;
+    double dblRequestID = 0;
 
     CheckInputArgument(pvApiCtx, 3, 3);
     CheckOutputArgument(pvApiCtx, 1, 1);
@@ -43,27 +44,32 @@ int sci_mpi_isend(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr2, &NodeID))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 2);
+        return 0;
     }
 
     sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
         return 0;
     }
 
-    if (getScalarDouble(pvApiCtx, piAddr3, &RequestID))
+    if (getScalarDouble(pvApiCtx, piAddr3, &dblRequestID))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 3);
+        return 0;
     }
 
-    if (RequestID < 0)
+    iRequestID = (int)dblRequestID;
+    if (iRequestID < 0)
     {
         Scierror(999, _("%s: Wrong values for input argument #%d: Positive value expected.\n"), fname, 3);
         return 0;
@@ -73,63 +79,35 @@ int sci_mpi_isend(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
         return 0;
     }
 
-    sciErr = getVarType(pvApiCtx, piAddr, &iType);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        return 0;
-    }
-
-    switch (iType)
-    {
-        case sci_matrix:
-            iRet = serialize_double(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_strings:
-            iRet = serialize_string(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = serialize_boolean(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = serialize_sparse(pvApiCtx, piAddr, &piBuffer, &iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = serialize_sparse(pvApiCtx, piAddr, &piBuffer, &iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = serialize_int(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        default:
-            Scierror(999, _("%s: Wrong values for input argument #%d: Unsupported '%s' type.\n"), fname, iType);
-            break;
-    }
-
+    //convert data from Scilab to MPI
+    iRet = serialize_to_mpi(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
     if (iRet)
     {
+        Scierror(999, _("Unable to serialize data\n"));
+        return 0;
     }
 
-    iRet = MPI_Isend(piBuffer, iBufferSize, MPI_INT, NodeID, TAG, MPI_COMM_WORLD, &request[(int)RequestID]);
+    iRet = MPI_Isend(piBuffer, iBufferSize, MPI_INT, (int)NodeID, TAG, MPI_COMM_WORLD, &request[iRequestID]);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: Could not send the variable to the node %d: %s\n", fname, NodeID, error_string);
-        return 1;
+        Scierror(999, _("%s: Could not send the variable to the node %d: %s\n"), fname, NodeID, error_string);
+        return 0;
     }
 
-    free(piBuffer);
-    if (createScalarBoolean(pvApiCtx, 1, !iRet))
+    if (createScalarBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, !iRet))
     {
-        return 1;
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
     }
 
-    AssignOutputVariable(pvApiCtx, 1) = 1;
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index d1d3d6c..1f94f7b 100644 (file)
@@ -15,6 +15,7 @@
 #include "gw_mpi.h"
 #include "Scierror.h"
 #include "MALLOC.h"
+#include "localization.h"
 #include "deserialization.h"
 
 int sci_mpi_recv(char *fname, unsigned long fname_len)
@@ -28,7 +29,6 @@ int sci_mpi_recv(char *fname, unsigned long fname_len)
     int *piAddr2 = NULL;
     double Tag = 0;
     double Rank = 0;
-
     MPI_Status status;
 
     CheckInputArgument(pvApiCtx, 2, 2);
@@ -39,12 +39,14 @@ int sci_mpi_recv(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr1, &Rank))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 1);
+        return 0;
     }
 
     //Tag
@@ -52,94 +54,67 @@ int sci_mpi_recv(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr2, &Tag))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 2);
+        return 0;
     }
 
-    /*
-        iRet = mpi_my_recv(&piBuffer, &iBufferSize);
-        if(iRet)
-        {
-            return 1;
-        }
-    */
-
-    iRet = MPI_Probe(Rank, Tag, MPI_COMM_WORLD, &status);
+    //wait message "Rank" node
+    iRet = MPI_Probe((int)Rank, (int)Tag, MPI_COMM_WORLD, &status);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: MPI_Probe failed. Rank %d / Tag %d: %s\n", fname, Rank, Tag, error_string);
-        return 1;
+        Scierror(999, _("%s: MPI_Probe failed. Rank %d / Tag %d: %s\n"), fname, Rank, Tag, error_string);
+        return 0;
     }
 
-    if (MPI_Get_count(&status, MPI_INT, &iBufferSize) != MPI_SUCCESS)
+    //get data size
+    iRet = MPI_Get_count(&status, MPI_INT, &iBufferSize);
+    if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: MPI_Get_count failed. Rank %d / Tag %d: %s\n", fname, Rank, Tag, error_string);
-        return 1;
+        Scierror(999, _("%s: MPI_Get_count failed. Rank %d / Tag %d: %s\n"), fname, Rank, Tag, error_string);
+        return 0;
     }
 
+    //alloc memory to receive data
     piBuffer = (int *)MALLOC(sizeof(int) * iBufferSize);
     if (piBuffer == NULL)
     {
-        Scierror(999, "%s: Could not create the received variable.\n", fname);
-        return 1;
+        Scierror(999, _("%s: Could not create the received variable.\n"), fname);
+        return 0;
     }
 
-    iRet = MPI_Recv(piBuffer, iBufferSize, MPI_INT, Rank, Tag, MPI_COMM_WORLD, &status);
+    //receive data
+    iRet = MPI_Recv(piBuffer, iBufferSize, MPI_INT, (int)Rank, (int)Tag, MPI_COMM_WORLD, &status);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: MPI_Recv failed. Rank %d / Tag %d: %s\n", fname, Rank, Tag, error_string);
-
-        return 1;
-    }
-
-    switch (piBuffer[0])
-    {
-        case sci_matrix:
-            iRet = deserialize_double(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_strings:
-            iRet = deserialize_string(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = deserialize_boolean(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = deserialize_int(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        default:
-            return 1;
-            break;
+        Scierror(999, _("%s: MPI_Recv failed. Rank %d / Tag %d: %s\n"), fname, Rank, Tag, error_string);
+        return 0;
     }
 
-    free(piBuffer);
+    //convert data from MPI to Scilab
+    iRet = deserialize_from_mpi(pvApiCtx, piBuffer, iBufferSize);
+    FREE(piBuffer);
     if (iRet)
     {
-        return 1;
+        Scierror(999, _("%s: Unable to deserialize data !\n"), fname);
+        return 0;
     }
 
-    AssignOutputVariable(pvApiCtx, 1) = 1;
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index 32e5b80..4b7a117 100644 (file)
@@ -20,7 +20,6 @@
 
 #define TAG 0
 
-
 int sci_mpi_send(char *fname, unsigned long fname_len)
 {
     SciErr sciErr;
@@ -40,75 +39,51 @@ int sci_mpi_send(char *fname, unsigned long fname_len)
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
         return 0;
     }
 
     if (getScalarDouble(pvApiCtx, piAddr2, &NodeID))
     {
-        return 1;
-    }
-
-    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 1);
         return 0;
     }
 
-    sciErr = getVarType(pvApiCtx, piAddr, &iType);
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
         return 0;
     }
 
-    switch (iType)
-    {
-        case sci_matrix:
-            iRet = serialize_double(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_strings:
-            iRet = serialize_string(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = serialize_boolean(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = serialize_sparse(pvApiCtx, piAddr, &piBuffer, &iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = serialize_sparse(pvApiCtx, piAddr, &piBuffer, &iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = serialize_int(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
-            break;
-        default:
-            Scierror(999, _("%s: Wrong values for input argument #%d: Unsupported '%s' type.\n"), fname, iType);
-            break;
-    }
-
+    //convert data from Scilab to MPI
+    iRet = serialize_to_mpi(pvApiCtx, piAddr, &piBuffer, &iBufferSize);
     if (iRet)
     {
+        Scierror(999, _("Unable to serialize data\n"));
+        return 0;
     }
 
-    iRet = MPI_Send(piBuffer, iBufferSize, MPI_INT, NodeID, TAG, MPI_COMM_WORLD);
+    //send data
+    iRet = MPI_Send(piBuffer, iBufferSize, MPI_INT, (int)NodeID, TAG, MPI_COMM_WORLD);
+    FREE(piBuffer);
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
-
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: Could not send the variable to the node %d: %s\n", fname, NodeID, error_string);
-        return 1;
+        Scierror(999, _("%s: Could not send the variable to the node %d: %s\n"), fname, NodeID, error_string);
+        return 0;
     }
 
-    free(piBuffer);
-    if (createScalarBoolean(pvApiCtx, 1, !iRet))
+    if (createScalarBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, !iRet))
     {
-        return 1;
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
     }
 
-    AssignOutputVariable(pvApiCtx, 1) = 1;
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index 7b9b0e7..504bd56 100644 (file)
@@ -28,89 +28,70 @@ int sci_mpi_wait(char *fname, unsigned long fname_len)
     SciErr sciErr;
     int iRet = 0;
     int *piAddr = NULL;
-    int *piAddr2 = NULL;
-    int iType = 0;
-    int iRows = 0;
-    int iCols = 0;
     int *piBuffer = NULL;
     int iBufferSize = 0;
     double NodeID = 0;
-    double RequestID;
+    int iRequestID;
+    double dblRequestID;
+    int iRank = 0;
 
-    CheckInputArgument(pvApiCtx, 1, 2);
+    CheckInputArgument(pvApiCtx, 1, 1);
     CheckOutputArgument(pvApiCtx, 1, 1);
 
     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
         return 0;
     }
 
-    if (getScalarDouble(pvApiCtx, piAddr, &RequestID))
+    if (getScalarDouble(pvApiCtx, piAddr, &dblRequestID))
     {
-        return 1;
+        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 1);
+        return 0;
     }
 
-    if (RequestID < 0)
+    iRequestID = (int)dblRequestID;
+
+    if (iRequestID < 0)
     {
         Scierror(999, _("%s: Wrong values for input argument #%d: Positive value expected.\n"), fname, 1);
         return 0;
     }
 
-    iRet = MPI_Wait(&request[(int)RequestID], MPI_STATUS_IGNORE); /* TODO: MPI_COMM_WORLD should be changed */
+    iRet = MPI_Wait(&request[iRequestID], MPI_STATUS_IGNORE); /* TODO: MPI_COMM_WORLD should be changed */
     if (iRet != MPI_SUCCESS)
     {
         char error_string[MPI_MAX_ERROR_STRING];
         int length_of_error_string;
 
         MPI_Error_string(iRet, error_string, &length_of_error_string);
-        Scierror(999, "%s: Failed to wait for the \n", fname, NodeID, error_string);
-        return 1;
+        Scierror(999, _("%s: Failed to wait %d: %s\n"), fname, NodeID, error_string);
+        return 0;
     }
 
     /* Restore the list */
-    piBuffer = listRequestPointer[(int)RequestID];
-    iBufferSize = listRequestPointerSize[(int)RequestID];
-    switch (piBuffer[0])
+    piBuffer = listRequestPointer[iRequestID];
+    iBufferSize = listRequestPointerSize[iRequestID];
+
+    if (iBufferSize == 0)
     {
-        case sci_matrix:
-            iRet = deserialize_double(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_strings:
-            iRet = deserialize_string(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_boolean:
-            iRet = deserialize_boolean(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        case sci_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, TRUE);
-            break;
-        case sci_boolean_sparse:
-            iRet = deserialize_sparse(pvApiCtx, piBuffer, iBufferSize, FALSE);
-            break;
-        case sci_ints:
-            iRet = deserialize_int(pvApiCtx, piBuffer, iBufferSize);
-            break;
-        default:
-            return 1;
-            break;
+        //wait on sender not on receiver
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+        ReturnArguments(pvApiCtx);
+        return 0;
     }
 
-    free(piBuffer);
+    iRet = deserialize_from_mpi(pvApiCtx, piBuffer, iBufferSize);
+    FREE(piBuffer);
     if (iRet)
     {
-        return 1;
+        Scierror(999, _("%s: Unable to deserialize data !\n"), fname);
+        return 0;
     }
 
-
-    /* free(piBuffer); */
-    /* if (createScalarDouble(pvApiCtx, 1, !iRet)) */
-    /* { */
-    /*     return 1; */
-    /* } */
-
-    AssignOutputVariable(pvApiCtx, 1) = 1;
+    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     ReturnArguments(pvApiCtx);
     return 0;
 }
index 4abd5aa..bfc0ebd 100644 (file)
  Don't touch if you do not know what you are doing
 -->
     <!-- =================== -->
-    <PRIMITIVE gatewayId="72" primitiveId="1" primitiveName="MPI_Init"/>
-    <PRIMITIVE gatewayId="72" primitiveId="2" primitiveName="MPI_Finalize"/>
-    <PRIMITIVE gatewayId="72" primitiveId="3" primitiveName="MPI_Comm_size"/>
-    <PRIMITIVE gatewayId="72" primitiveId="4" primitiveName="MPI_Comm_rank"/>
-    <PRIMITIVE gatewayId="72" primitiveId="5" primitiveName="MPI_Recv"/>
-    <PRIMITIVE gatewayId="72" primitiveId="6" primitiveName="MPI_Send"/>
-    <PRIMITIVE gatewayId="72" primitiveId="7" primitiveName="MPI_Get_processor_name"/>
-    <PRIMITIVE gatewayId="72" primitiveId="8" primitiveName="MPI_Bcast"/>
-    <PRIMITIVE gatewayId="72" primitiveId="9" primitiveName="MPI_Irecv"/>
-    <PRIMITIVE gatewayId="72" primitiveId="10" primitiveName="MPI_Isend"/>
-    <PRIMITIVE gatewayId="72" primitiveId="11" primitiveName="MPI_Wait"/>
+    <PRIMITIVE gatewayId="73" primitiveId="1" primitiveName="MPI_Init"/>
+    <PRIMITIVE gatewayId="73" primitiveId="2" primitiveName="MPI_Finalize"/>
+    <PRIMITIVE gatewayId="73" primitiveId="3" primitiveName="MPI_Comm_size"/>
+    <PRIMITIVE gatewayId="73" primitiveId="4" primitiveName="MPI_Comm_rank"/>
+    <PRIMITIVE gatewayId="73" primitiveId="5" primitiveName="MPI_Recv"/>
+    <PRIMITIVE gatewayId="73" primitiveId="6" primitiveName="MPI_Send"/>
+    <PRIMITIVE gatewayId="73" primitiveId="7" primitiveName="MPI_Get_processor_name"/>
+    <PRIMITIVE gatewayId="73" primitiveId="8" primitiveName="MPI_Bcast"/>
+    <PRIMITIVE gatewayId="73" primitiveId="9" primitiveName="MPI_Irecv"/>
+    <PRIMITIVE gatewayId="73" primitiveId="10" primitiveName="MPI_Isend"/>
+    <PRIMITIVE gatewayId="73" primitiveId="11" primitiveName="MPI_Wait"/>
 </GATEWAY>
diff --git a/scilab/modules/mpi/src/c/DllmainMpi.c b/scilab/modules/mpi/src/c/DllmainMpi.c
new file mode 100644 (file)
index 0000000..ded04ab
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#include <windows.h>
+/*--------------------------------------------------------------------------*/
+#pragma comment(lib,"../../bin/libintl.lib")
+#pragma comment(lib,"../../bin/blasplus.lib")
+
+#pragma comment(lib,"../../bin/libmpi.lib")
+
+
+/*--------------------------------------------------------------------------*/
+int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
+{
+    switch (reason)
+    {
+        case DLL_PROCESS_ATTACH:
+            break;
+        case DLL_PROCESS_DETACH:
+            break;
+        case DLL_THREAD_ATTACH:
+            break;
+        case DLL_THREAD_DETACH:
+            break;
+    }
+    return 1;
+}
+/*--------------------------------------------------------------------------*/
+
index 72be0b3..6bbcba2 100644 (file)
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "sci_types.h"
-#include "BOOL.h"
 #include "api_scilab.h"
-#include "stack1.h"
+#include "BOOL.h"
 #include "MALLOC.h"
+#include "deserialization.h"
 
-int deserialize_double(void *_pvCtx, int *_piBuffer, int _iBufferSize)
+static int deserialize_double(void *_pvCtx, int *_piBuffer, int _iBufferSize)
 {
     SciErr sciErr;
     int iRows = _piBuffer[1];
@@ -41,11 +40,11 @@ int deserialize_double(void *_pvCtx, int *_piBuffer, int _iBufferSize)
 
     if (iComplex)
     {
-        sciErr = createComplexMatrixOfDouble(_pvCtx, 1, iRows, iCols, pdblR, pdblI);
+        sciErr = createComplexMatrixOfDouble(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, pdblR, pdblI);
     }
     else
     {
-        sciErr = createMatrixOfDouble(_pvCtx, 1, iRows, iCols, pdblR);
+        sciErr = createMatrixOfDouble(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, pdblR);
     }
 
     if (sciErr.iErr)
@@ -57,7 +56,7 @@ int deserialize_double(void *_pvCtx, int *_piBuffer, int _iBufferSize)
     return 0;
 }
 
-int deserialize_string(void *_pvCtx, int *_piBuffer, int _iBufferSize)
+static int deserialize_string(void *_pvCtx, int *_piBuffer, int _iBufferSize)
 {
     SciErr sciErr;
     int i = 0;
@@ -90,22 +89,23 @@ int deserialize_string(void *_pvCtx, int *_piBuffer, int _iBufferSize)
         printf("Bad buffer size: \n\tReceived: %d\n\tExpected: %d\n", _iBufferSize, iSize);
         return 1;
     }
-    pstData = (char **)malloc(iRows * iCols * sizeof(char *));
+    pstData = (char **)MALLOC(iRows * iCols * sizeof(char *));
 
     for (i = 0; i < iRows * iCols; i++)
     {
-        pstData[i] = (char *)malloc((piInLen[i] + 1) * sizeof(char));
+        pstData[i] = (char *)MALLOC((piInLen[i] + 1) * sizeof(char));
         memcpy(pstData[i], pstInData, piInLen[i]);
         pstData[i][piInLen[i]] = 0;
         pstInData += piInLen[i];
     }
 
-    sciErr = createMatrixOfString(_pvCtx, 1, iRows, iCols, (const char * const *)pstData);
+    sciErr = createMatrixOfString(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (const char * const *)pstData);
     for (i = 0; i < iRows * iCols; i++)
     {
-        free(pstData[i]);
+        FREE(pstData[i]);
     }
-    free(pstData);
+
+    FREE(pstData);
 
     if (sciErr.iErr)
     {
@@ -116,7 +116,7 @@ int deserialize_string(void *_pvCtx, int *_piBuffer, int _iBufferSize)
     return 0;
 }
 
-int deserialize_boolean(void *_pvCtx, int *_piBuffer, int _iBufferSize)
+static int deserialize_boolean(void *_pvCtx, int *_piBuffer, int _iBufferSize)
 {
     SciErr sciErr;
     int iRows = _piBuffer[1];
@@ -133,7 +133,7 @@ int deserialize_boolean(void *_pvCtx, int *_piBuffer, int _iBufferSize)
     }
 
     piBool = _piBuffer + 4;
-    sciErr = createMatrixOfBoolean(_pvCtx, 1, iRows, iCols, piBool);
+    sciErr = createMatrixOfBoolean(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, piBool);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
@@ -143,7 +143,7 @@ int deserialize_boolean(void *_pvCtx, int *_piBuffer, int _iBufferSize)
     return 0;
 }
 
-int deserialize_int(void *_pvCtx, int *_piBuffer, int _iBufferSize)
+static int deserialize_int(void *_pvCtx, int *_piBuffer, int _iBufferSize)
 {
     SciErr sciErr;
     int iRows = _piBuffer[1];
@@ -194,29 +194,29 @@ int deserialize_int(void *_pvCtx, int *_piBuffer, int _iBufferSize)
     switch (iPrecision)
     {
         case SCI_INT8:
-            sciErr = createMatrixOfInteger8(_pvCtx, 1, iRows, iCols, (char *)pvData);
+            sciErr = createMatrixOfInteger8(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (char *)pvData);
             break;
         case SCI_UINT8:
-            sciErr = createMatrixOfUnsignedInteger8(_pvCtx, 1, iRows, iCols, (unsigned char *)pvData);
+            sciErr = createMatrixOfUnsignedInteger8(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (unsigned char *)pvData);
             break;
         case SCI_INT16:
-            sciErr = createMatrixOfInteger16(_pvCtx, 1, iRows, iCols, (short *)pvData);
+            sciErr = createMatrixOfInteger16(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (short *)pvData);
             break;
         case SCI_UINT16:
-            sciErr = createMatrixOfUnsignedInteger16(_pvCtx, 1, iRows, iCols, (unsigned short *)pvData);
+            sciErr = createMatrixOfUnsignedInteger16(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (unsigned short *)pvData);
             break;
         case SCI_INT32:
-            sciErr = createMatrixOfInteger32(_pvCtx, 1, iRows, iCols, (int *)pvData);
+            sciErr = createMatrixOfInteger32(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (int *)pvData);
             break;
         case SCI_UINT32:
-            sciErr = createMatrixOfUnsignedInteger32(_pvCtx, 1, iRows, iCols, (unsigned int *)pvData);
+            sciErr = createMatrixOfUnsignedInteger32(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (unsigned int *)pvData);
             break;
             /*
                 case SCI_INT64 :
-                    sciErr = createMatrixOfInteger64(_pvCtx, 1, iRows, iCols, (long long*)pvData);
+                    sciErr = createMatrixOfInteger64(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (long long*)pvData);
                     break;
                 case SCI_UINT64 :
-                    sciErr = createMatrixOfUnsignedInteger64(_pvCtx, 1, iRows, iCols, (unsigned long long*)pvData);
+                    sciErr = createMatrixOfUnsignedInteger64(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, (unsigned long long*)pvData);
                     break;
             */
         default:
@@ -231,7 +231,7 @@ int deserialize_int(void *_pvCtx, int *_piBuffer, int _iBufferSize)
     return 0;
 }
 
-int deserialize_sparse(void *_pvCtx, int *_piBuffer, int _iBufferSize, BOOL _bData)
+static int deserialize_sparse(void *_pvCtx, int *_piBuffer, int _iBufferSize, BOOL _bData)
 {
     SciErr sciErr;
     int iRows = _piBuffer[1];
@@ -266,16 +266,16 @@ int deserialize_sparse(void *_pvCtx, int *_piBuffer, int _iBufferSize, BOOL _bDa
         if (iComplex)
         {
             pdblI = pdblR + iItemCount;
-            sciErr = createComplexSparseMatrix(_pvCtx, 1, iRows, iCols, iItemCount, piRowCount, piColPos, pdblR, pdblI);
+            sciErr = createComplexSparseMatrix(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, iItemCount, piRowCount, piColPos, pdblR, pdblI);
         }
         else
         {
-            sciErr = createSparseMatrix(_pvCtx, 1, iRows, iCols, iItemCount, piRowCount, piColPos, pdblR);
+            sciErr = createSparseMatrix(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, iItemCount, piRowCount, piColPos, pdblR);
         }
     }
     else
     {
-        sciErr = createBooleanSparseMatrix(_pvCtx, 1, iRows, iCols, iItemCount, piRowCount, piColPos);
+        sciErr = createBooleanSparseMatrix(_pvCtx, nbInputArgument(_pvCtx) + 1, iRows, iCols, iItemCount, piRowCount, piColPos);
     }
 
     if (sciErr.iErr)
@@ -285,3 +285,26 @@ int deserialize_sparse(void *_pvCtx, int *_piBuffer, int _iBufferSize, BOOL _bDa
     }
     return 0;
 }
+
+int deserialize_from_mpi(void *_pvCtx, int *_piBuffer, int _iBufferSize)
+{
+    switch (*_piBuffer)
+    {
+        case sci_matrix:
+            return deserialize_double(pvApiCtx, _piBuffer, _iBufferSize);
+        case sci_strings:
+            return deserialize_string(pvApiCtx, _piBuffer, _iBufferSize);
+        case sci_boolean:
+            return deserialize_boolean(pvApiCtx, _piBuffer, _iBufferSize);
+        case sci_sparse:
+            return deserialize_sparse(pvApiCtx, _piBuffer, _iBufferSize, TRUE);
+        case sci_boolean_sparse:
+            return deserialize_sparse(pvApiCtx, _piBuffer, _iBufferSize, FALSE);
+        case sci_ints:
+            return deserialize_int(pvApiCtx, _piBuffer, _iBufferSize);
+        default:
+            return -1; //unknow type
+    }
+}
+
+
index 770e1f7..1d403c1 100644 (file)
  */
 
 /**
- * Deserialize a double and return a double Scilab variable
+ * Deserialize a mpi data to a Scilab variable
  *
  * @param _pvCtx The runtime context
  * @param _piBuffer The buffer
  * @param _iBufferSize The size of the buffer
  * @return 0 in case of success
  */
-int deserialize_double(void *_pvCtx, int *_piBuffer, int _iBufferSize);
-
-/**
- * Deserialize a string and return a string Scilab variable
- *
- * @param _pvCtx The runtime context
- * @param _piBuffer The buffer
- * @param _iBufferSize The size of the buffer
- * @return 0 in case of success
- */
-int deserialize_string(void *_pvCtx, int *_piBuffer, int _iBufferSize);
-
-/**
- * Deserialize a boolean and return a boolean Scilab variable
- *
- * @param _pvCtx The runtime context
- * @param _piBuffer The buffer
- * @param _iBufferSize The size of the buffer
- * @return 0 in case of success
- */
-int deserialize_boolean(void *_pvCtx, int *_piBuffer, int _iBufferSize);
-
-/**
- * Deserialize an int and return a int Scilab variable
- *
- * @param _pvCtx The runtime context
- * @param _piBuffer The buffer
- * @param _iBufferSize The size of the buffer
- * @return 0 in case of success
- */
-int deserialize_int(void *_pvCtx, int *_piBuffer, int _iBufferSize);
-
-/**
- * Deserialize a sparse and return a sparse Scilab variable
- *
- * @param _pvCtx The runtime context
- * @param _piBuffer The buffer
- * @param _iBufferSize The size of the buffer
- * @return 0 in case of success
- */
-int deserialize_sparse(void *_pvCtx, int *_piBuffer, int _iBufferSize, BOOL _bData);
+int deserialize_from_mpi(void *_pvCtx, int *_piBuffer, int _iBufferSize);
diff --git a/scilab/modules/mpi/src/c/mpi.rc b/scilab/modules/mpi/src/c/mpi.rc
new file mode 100644 (file)
index 0000000..cf648f5
--- /dev/null
@@ -0,0 +1,96 @@
+// Microsoft Visual C++ generated resource script.
+//
+
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// French (France) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
+#ifdef _WIN32
+LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 5,5,0,0
+ PRODUCTVERSION 5,5,0,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040c04b0"
+        BEGIN
+            VALUE "FileDescription", "mpi module"
+            VALUE "FileVersion", "5, 5, 0, 0"
+            VALUE "InternalName", "mpi module"
+            VALUE "LegalCopyright", "Copyright (C) 2013"
+            VALUE "OriginalFilename", "mpi.dll"
+            VALUE "ProductName", " mpi module"
+            VALUE "ProductVersion", "5, 5, 0, 0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x40c, 1200
+    END
+END
+
+#endif    // French (France) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
index 09f3cc8..2f76618 100644 (file)
  */
 #include <stdio.h>
 #include <mpi.h>
-#include "malloc.h"
+#include "MALLOC.h"
 
 int pre_send_metadata(int size, MPI_Datatype dataType, int dest, int tag)
 {
     /* Find out the buffer size */
-    int mpi_buffsize = (1*sizeof(int)) + (1*sizeof(MPI_Datatype));
-    char *mpi_buff = (char *) malloc(mpi_buffsize *sizeof(char));
+    int mpi_buffsize = (1 * sizeof(int)) + (1 * sizeof(MPI_Datatype));
+    char *mpi_buff = (char *) MALLOC(mpi_buffsize * sizeof(char));
     int position = 0;
 
     /* Serialize both size and type to send it the slave */
@@ -25,20 +25,21 @@ int pre_send_metadata(int size, MPI_Datatype dataType, int dest, int tag)
     MPI_Pack(&dataType, 1, MPI_INT, mpi_buff, mpi_buffsize, &position, MPI_COMM_WORLD);
     MPI_Send(mpi_buff, position, MPI_PACKED, dest, tag, MPI_COMM_WORLD);
     /* TODO: check this result */
-    free(mpi_buff);
-
+    FREE(mpi_buff);
+    return 0;
 }
 
 int pre_recv_metadata(int source, int tag, int *size, MPI_Datatype *dataType)
 {
     int position = 0;
-    MPI_Status stat; 
-    int mpi_buffsize = (1*sizeof(int)) + (1*sizeof(MPI_Datatype));
-    char *mpi_buff = (char *) malloc(mpi_buffsize *sizeof(char));
+    MPI_Status stat;
+    int mpi_buffsize = (1 * sizeof(int)) + (1 * sizeof(MPI_Datatype));
+    char *mpi_buff = (char *) MALLOC(mpi_buffsize * sizeof(char));
 
     /* DeSerialize both size and type from the master */
     MPI_Recv(mpi_buff, mpi_buffsize, MPI_PACKED, source, tag, MPI_COMM_WORLD, &stat);
-/* TODO: check stat */
+    /* TODO: check stat */
     MPI_Unpack(mpi_buff, mpi_buffsize, &position, &size, 1, MPI_INT, MPI_COMM_WORLD);
     MPI_Unpack(mpi_buff, mpi_buffsize, &position, &dataType, 1, MPI_INT, MPI_COMM_WORLD);
+    return 0;
 }
index ff472e2..b4859f5 100644 (file)
@@ -1,16 +1,15 @@
 
 #ifndef __SCIMPI
 #define __SCIMPI
+
+
 #include <stdlib.h>
 #include <mpi.h>
 
 /* Create some static datastructure to store all the Request references */
 MPI_Request *request;
-int *listRequestPointer;
+int **listRequestPointer;
 int *listRequestPointerSize;
 static int REQUEST_MAXSIZE = 10000;
 
-
-#define debuglevel 10
-
 #endif /* __SCIMPI */
index 4f6ed15..2925f57 100644 (file)
  */
 #include <string.h>
 #include <stdio.h>
-#include "sci_types.h"
-#include "BOOL.h"
 #include "api_scilab.h"
-#include "stack1.h"
+#include "BOOL.h"
 #include "MALLOC.h"
+#include "serialization.h"
 
-int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
+static int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
     SciErr sciErr;
     int iRows = 0;
@@ -84,7 +83,7 @@ int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
         piOut[2] = iCols;
         piOut[3] = 0;           //not complex
 
-        //move 'p' to first complex value
+        //move 'p' to first value
         p = (double *)(piOut + 4);
         iSize = iRows * iCols;
         C2F(dcopy) (&iSize, pdblR, &iOne, p, &iOne);
@@ -95,7 +94,7 @@ int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
     return 0;
 }
 
-int serialize_string(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
+static int serialize_string(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
     int iErr = 0;
     int i = 0;
@@ -116,7 +115,7 @@ int serialize_string(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
 
     for (i = 0; i < iRows * iCols; i++)
     {
-        iOutLen += strlen(pstData[i]);
+        iOutLen += (int)strlen(pstData[i]);
     }
 
     if (iOutLen % 4)
@@ -146,7 +145,7 @@ int serialize_string(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
 
     for (i = 0; i < iRows * iCols; i++)
     {
-        piOutLen[i] = strlen(pstData[i]);
+        piOutLen[i] = (int)strlen(pstData[i]);
     }
 
     p = (char *)(piOut + 4 + iRows * iCols);
@@ -161,7 +160,7 @@ int serialize_string(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
     return 0;
 }
 
-int serialize_boolean(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
+static int serialize_boolean(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
     SciErr sciErr;
     int iRows = 0;
@@ -201,7 +200,7 @@ int serialize_boolean(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffe
     return 0;
 }
 
-int serialize_int(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
+static int serialize_int(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
     SciErr sciErr;
     int iPrecision = 0;
@@ -240,12 +239,12 @@ int serialize_int(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSiz
     {
         iItemSize = sizeof(int);
     }
-/*
-    else if(iPrecision == SCI_INT64 || iPrecision == SCI_UINT64)
-    {
-        iItemSize = sizeof(long long);
-    }
-*/
+    /*
+        else if(iPrecision == SCI_INT64 || iPrecision == SCI_UINT64)
+        {
+            iItemSize = sizeof(long long);
+        }
+    */
     //check and adjust alignement on integer
     iOutLen = iRows * iCols;
     if ((iOutLen * iItemSize) % sizeof(int))
@@ -271,49 +270,49 @@ int serialize_int(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSiz
 
     switch (iPrecision)
     {
-    case SCI_INT8:
+        case SCI_INT8:
         {
             sciErr = getMatrixOfInteger8(_pvCtx, _piAddr, &iRows, &iCols, (char **)&pvData);
             break;
         }
-    case SCI_UINT8:
+        case SCI_UINT8:
         {
             sciErr = getMatrixOfUnsignedInteger8(_pvCtx, _piAddr, &iRows, &iCols, (unsigned char **)&pvData);
             break;
         }
-    case SCI_INT16:
+        case SCI_INT16:
         {
             sciErr = getMatrixOfInteger16(_pvCtx, _piAddr, &iRows, &iCols, (short **)&pvData);
             break;
         }
-    case SCI_UINT16:
+        case SCI_UINT16:
         {
             sciErr = getMatrixOfUnsignedInteger16(_pvCtx, _piAddr, &iRows, &iCols, (unsigned short **)&pvData);
             break;
         }
-    case SCI_INT32:
+        case SCI_INT32:
         {
             sciErr = getMatrixOfInteger32(_pvCtx, _piAddr, &iRows, &iCols, (int **)&pvData);
             break;
         }
-    case SCI_UINT32:
+        case SCI_UINT32:
         {
             sciErr = getMatrixOfUnsignedInteger32(_pvCtx, _piAddr, &iRows, &iCols, (unsigned int **)&pvData);
             break;
         }
-/*
-    case SCI_INT64 :
-    { 
-        sciErr = getMatrixOfInteger64(_pvCtx, _piAddr, &iRows, &iCols, (long long**)&pvData);
-        break;
-    }
-    case SCI_UINT64 :
-    { 
-        sciErr = getMatrixOfUnsignedInteger64(_pvCtx, _piAddr, &iRows, &iCols, (unsigned long long**)&pvData);
-        break;
-        }
-*/ default:
-        return 1;
+        /*
+            case SCI_INT64 :
+            {
+                sciErr = getMatrixOfInteger64(_pvCtx, _piAddr, &iRows, &iCols, (long long**)&pvData);
+                break;
+            }
+            case SCI_UINT64 :
+            {
+                sciErr = getMatrixOfUnsignedInteger64(_pvCtx, _piAddr, &iRows, &iCols, (unsigned long long**)&pvData);
+                break;
+                }
+        */ default:
+            return 1;
     }
 
     if (sciErr.iErr)
@@ -329,7 +328,7 @@ int serialize_int(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSiz
     return 0;
 }
 
-int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize, BOOL _bData)
+static int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize, BOOL _bData)
 {
     int iRet = 0;
     int iRows = 0;
@@ -346,7 +345,8 @@ int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
     int iOutLen = 0;
 
     if (_bData)
-    {                           //sparse
+    {
+        //sparse
 
         iComplex = isVarComplex(_pvCtx, _piAddr);
         if (iComplex)
@@ -359,7 +359,8 @@ int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
         }
     }
     else
-    {                           //boolean sparse
+    {
+        //boolean sparse
         iRet = getAllocatedBooleanSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItemCount, &piRowCount, &piColPos);
     }
 
@@ -405,3 +406,31 @@ int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBuffer
     *_piBufferSize = iOutLen;
     return 0;
 }
+
+int serialize_to_mpi(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
+{
+    switch (*_piAddr)
+    {
+        case sci_matrix:
+            return serialize_double(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            break;
+        case sci_strings:
+            return serialize_string(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            break;
+        case sci_boolean:
+            return serialize_boolean(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            break;
+        case sci_sparse:
+            return serialize_sparse(pvApiCtx, _piAddr, _piBuffer, _piBufferSize, TRUE);
+            break;
+        case sci_boolean_sparse:
+            return serialize_sparse(pvApiCtx, _piAddr, _piBuffer, _piBufferSize, FALSE);
+            break;
+        case sci_ints:
+            return serialize_int(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            break;
+        default:
+            return -1;
+            break;
+    }
+}
\ No newline at end of file
index 3cec6cb..be1da13 100644 (file)
  *
  */
 
-int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize);
-int serialize_string(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize);
-int serialize_boolean(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize);
-int serialize_int(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize);
-int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize, BOOL _bData);
+/**
+ * Serialize a Scilab variable to mpi data
+ *
+ * @param _pvCtx The runtime context
+ * @param _piBuffer The buffer
+ * @param _iBufferSize The size of the buffer
+ * @return 0 in case of success
+ */
+
+int serialize_to_mpi(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize);