July 2008 - Posts

PHP4Live - PHP SOAP Win32 Build Environment

Hacking PHP extension on Windows is "little bit" harder. I had a good challenge when trying to make it works on my Vista machine using VC++ 2008 Express (and Windows Vista SDK) for our PHP4Live project. I called Pak Tahir and he told me that easier to use Cygwin DLL, but again, my boldness drove me nuts!. I want to prove that Vista can do that well. Let me share with you (in this long post) to avoid you from doing stupid thing in around 10 hours!

PHP4Live Overview
In our PHP4Live project we want to be able to customize PHP SOAP extension as we want to embed Windows Live ID web and delegated authentication mechanisms. The plan is to natively link Windows Live (WL) Web Services and expose its APIs as PHP 5 user-space scripts, means that we will make PHP extension for Windows Live. This type of extension can bridge the gap between WL Services APIs and the PHP core then seamlessly increase usability of WL Service APIs among PHP developers (hopefully). Beside of usability reason, other motivation for PHP Extension for Window is the sheer need for speed. PHP script code has to be tokenized, compiled, and stepped through in PHP VM environment, which can never be as fast as native code. Certain utilities (known as Opcode Caches) can allow scripts to skip the tokenization and compilation step on repeated execution, but they can never speed up the execution step. By translating it to C code and compile it as PHP extension DLL, the maintainer sacrifices some of the ease of design that makes PHP Extension for WL more powerful.

PHP SOAP Extension
PHP SOAP inside the PHP distribution is an "experimental" extension that can be used to write SOAP (1.1, 1.2 and WSDL 1.1 specs) Server and Client. It is not complete like WSF/PHP from WSO2, but I was thinking this is pretty simple as our PHP4Live base code and I want to prepare build environment for it. So I took the code from PHP source ext/soap, then I moved it to my working directory in C:/Work/PHP-SOAP. I clicked the dsw (VC++ 6.0 based) and followed VC++ 2008 migration wizard successfully. Then I had:

01

First compilation, I got around 100 warnings and 50 error messages. I thought I can fix that within 3 hours, but thing was getting worst!. Why? Because to compile PHP SOAP I need the following libraries:

- odbc32.lib
- odbccp32.lib
- wsock32.lib
- libxml2.lib                      
- resolv.lib                
- php5ts_debug.lib  

All green color libraries are coming with Windows Vista SDKs and the blue one is the GNOME XML Library, that maintained by Igor Zlatkovic. You can download Libxml 2.6.32 from Igor website or from XMLSoft. My biggest problem was resolv.lib and php5ts_debug.lib, because I had to compile it directly from PHP source codes.

Building PHP from Source
This my step-by-step quick-start guide to build PHP using Windows Vista and VC++ 2008 Express edition. First, create

1. Download and Install Windows SDK for Windows Server 2008 and .NET Framework 3.5
2. Copy C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\WinResrc.h
    to the same directory then rename it as WinRes.h.
3. Create the directory C:\work.
4. Download Windows build tools and unzip the contents into C:\work.
5. Create the directory C:\usr\local\lib. Copy the C:\work\win32build\bin\bison.simple
    into the new directory.
6. Download Windows DNS resolver library and unzip into C:\work.
7. Open C:\work\bindlib_w32\bindlib.dsw, follow migration wizard.
    Choose Debug or Release configuration, then Build => Build Solution.
    Make sure you have set the Additional Include Directories like below:
 
05

8. Get copy of the PHP source and extract it into the C:\work directory, I use PHP 5.2.6.
    At this point, that directory should look something like this:

06 

   Note : As we will need iconv library, please download from Igor website.

9. Open Visual Studio 2008 Command Prompt and execute the following command:

C:\Program Files\Microsoft Visual Studio 9.0\VC> set "PATH=C:\work\win32build\bin;%PATH%"

10. Go to PHP-5-2-6 directory and run : cscript /nologo win32\build\buildconf.js

11. Run : cscript /nologo configure.js --disable-all --enable-cli --enable-cgi
     --enable-object-out-dir=.. --disable-ipv6.
     To enable debugging, add --enable-debug to the end.

12. Run : nmake

If all went well, from step #7 you will get resolv.lib in bindlib project debug folder and from step #12 you will get php5ts_debug.lib in Debug_TS or Release_TS folder. Also, it means you are ready to compile PHP SOAP.


PHP SOAP Build Environment
Ok lets start. First, you have to configure your VCE "Additional Include Directories" under C/C++ option to make use all header files before doing the compilation, here is my configuration:

02 

After you set the include directories, now you have to set the "additional library directories" under linker options for linking purpose. Below is how it looks like. There is Windows SDK and LIBXML 2.6.32+ lib locations. Make sure you put C:\Work\Debug_TS where php5ts_debug.lib located. Also C:\Work\bindlib_w32\Debug where resolv.lib located.

04 


I believe you still get some error messages if you compile PHP SOAP, but don't be panic, error messages are bonuses for us (image if there the error has no message). If the error points you to system header files stat.inl and utime.inl, I know how to fix it.

Error 3 error C2466: cannot allocate an array of constant size 0   
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\sys\stat.inl    44

Error 6 error C2466: cannot allocate an array of constant size 0   
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\sys\utime.inl    39

Just add _USE_32BIT_TIME_T in the preprocessor definitions and you are DONE!. I am sure you can compile PHP SOAP successfully now. But you will find at least 3 errors in linking process.

03 

BUGS in PHP SOAP EXTENSION (PHP 5.2.6 WIN32)
As PHP SOAP is an experimental extension, bugs are very welcome. I currently found that there are two bugs related to LIBXML2 Win32 linking that cause LNK2019.

1> Creating library .\Debug_TS/php_soap.lib and object .\Debug_TS/php_soap.exp
1> php_encoding.obj : error LNK2019: unresolved external symbol
     _php_libxml_xmlCheckUTF8 referenced in function _to_xml_string
1> php_sdl.obj : error LNK2019: unresolved external symbol
    
_php_libxml_switch_context
referenced in function _get_sdl
1>.\Debug_TS/php_soap.dll : fatal error LNK1120: 2 unresolved externals

Why I said bugs? If I try to comment part of codes in php_encoding.c and php_sdl.c that doing function call the following methods:

- php_libxml_xmlCheckUTF8(BAD_CAST(str))
- php_libxml_switch_context(new_context TSRMLS_CC)

No problem at all. I can compile PHP SOAP and get its DLL extension very well! I don't know how long time I can mitigate this LIBXML bugs, but I believe should be less than 10 hours!. Now I need sleep!

Note for Zeddy: Can you try in *NIX machine?

Ciao - RAM

Share this post: | | | |

Programming with PowerShell SDK | Part 2

In this tutorial, I would like to show you how to build your first CMDLET (command let) using C# and PowerShell SDK. We will make the simplest one as our HelloWorld, only to learn the skeleton of creating it. Many things we can do with CMDLET. For example, some folks make CMDLET for IIS 7.0 Management, SQL Server 2008, TFS, Sharepoint etc. Maybe myself should release one for MSMPI for example hmmm, spicy!. Ok, let start!

Basically, cmdlets are .NET class, derived from abstract classes:

- System.Management.Automation.Cmdlet or
- System.Management.Automation.PSCmdlet

and what we should do is to override some methods with our needs. The cmdlet assembly then can be installed to the PowerShell and can be used from PowerShell or from other applications which use the PowerShell to Invoke cmdlets.

A cmdlet has a name, that consists of a verb that indicates the action the cmdlet takes and a noun that indicates the items that the cmdlet acts upon. For example Get-Proc, it uses the verb "Get", defined by the VerbsCommon enumeration, and the noun "Service" to indicate that the cmdlet works on service items. When naming cmdlets, do not use any of the following characters: # , () {} [] & - /\ $ ; : ” ’<> | ? @ `. We should choose a noun that is specific. It is best to use a singular noun prefixed with a shortened version of the product name, for example Get-Proc.

Once we have chosen a name for our cmdlet, define a .NET class to implement the cmdlet, here is the class definition for Get-Proc cmdlet:

[Cmdlet(VerbsCommon.Get, "Proc")]
public class GetProcCommand : Cmdlet 

The class for a cmdlet must be explicitly marked as public. Classes that are not marked as public will default to internal and will not be found by the Windows PowerShell runtime. CmdletAttribute attribute, with the syntax [Cmdlet(verb, noun, …)], is used to identify this class as a cmdlet. This is the only required attribute for all cmdlets, and it allows the Windows PowerShell runtime to call them correctly. It is a good practice to reflect the cmdlet name in the class name. To do this, use the form "VerbNounCommand" and replace "Verb" and "Noun" with the verb and noun used in the cmdlet name.

Cmdlet class can derived from both Cmdlet and PSCmdlet abstract classes. It depends on deep we would like to integrate with PowerShell runtime, let say access to session state data, call scripts etc. When deriving from Cmdlets, we aren't really depend on Powershell. We are not impacted by any changes in PowerShell runtime. Our cmdlet can invoke directly from any application instead of invoking it through the Windows PowerShell runtime. In most cases, deriving from Cmdlet is the common choice.

ps01.jgp 

The Cmdlet class provides three main input processing methods, at least one of which your cmdlet must override.

BeginProcessing
For all types of input, the Windows PowerShell runtime calls BeginProcessing to enable processing. If our cmdlet must perform some preprocessing or setup, it can do this by overriding this method. Windows PowerShell uses the term "record" to describe the set of parameter values supplied when a cmdlet is called.

ProcessRecord
If your cmdlet accepts pipeline input, it must override the ProcessRecord method. For example, a cmdlet might override both methods if it gathers all input using ProcessRecord and then operates on the input as a whole rather than one element at a time, as the Sort-Object cmdlet does.

EndProcessing
This method is used optionally to end the pipeline input. Means that EndProcessing is optional when if we use ProcessRecord method to accepts pipeline input.  If our cmdlet does not take pipeline input, it should override the EndProcessing method. Be aware that this method is frequently used in place of BeginProcessing when the cmdlet cannot operate on one element at a time.

For example, because our sample Get-Proc cmdlet must receive pipeline input, it overrides the ProcessRecord method and uses the default implementations for BeginProcessing and EndProcessing. Some cmdlet might have object variables to clean up when it is finished processing (for example, if it opens a file handle in the BeginProcessing method and keeps the handle open for use by ProcessRecord). It is important to remember that the Windows PowerShell runtime does not always call the EndProcessing method, which should perform object cleanup. For example, EndProcessing might not be called if the cmdlet is canceled midway or if a terminating error occurs in any part of the cmdlet. Therefore, a cmdlet that requires object cleanup should implement the complete IDisposable pattern, including the finalizer, so that the runtime can call both EndProcessing and Dispose at the end of processing.


Here is my simple codes to show OS processes stream :

//This class implements a Get-Proc cmdlet that has no parameters.
[Cmdlet(VerbsCommon.Get, "Proc")]
public class GetProcCommand : Cmdlet
{
    protected override void BeginProcessing()
    {
        base.BeginProcessing();
    }

    protected override void ProcessRecord()
    {
        // Get the current processes from Diagnostic Object
        Process[] processes = Process.GetProcesses();
        WriteObject(processes, true);
    }

}

How to Register Cmdlets
There are two mechanisms that can be used to register our Get-Proc cmdlet:
1 - Extending the shell using a snap-in (commonly used)
2 - Registering with a custom shell

I used the first one using a snap-in. This registration mechanism does not require a new shell, but adds the cmdlet to the current session or a saved session. A Windows Powershell snap-in can register all the cmdlets in a single assembly, or it can register a specific list of cmdlets. Note : snap-in assembly should be installed into a protected directory; otherwise, an unauthorized user could replace your assembly with malicious code.

To write a snap-in that register our cmdlet in its assembly, our snap-in class must derive from the PSSnapIn class. Here our simple codes look like:

  // Create the PowerShell snap-in used to register Get-Proc CmdLet
  [RunInstaller(true)]
  public class GetProcPSSnapIn : PSSnapIn
  {
      //Create an instance
      public GetProcPSSnapIn(): base(){}
     
      // Specify the name of the PowerShell snap-in.
      public override string Name
      {
          get
          {
              return "GetProcPSSnapIn";
          }
      }

      //Specify the vendor for the PowerShell snap-in.
      public override string Vendor
      {
          get
          {
              return "RAM";
          }
      }

      //Specify the localization resource information for the vendor.
      public override string VendorResource
      {
          get
          {
              return "GetProcPSSnapIn,RAM";
          }
      }

      //Specify a description of the PowerShell snap-in.
      public override string Description
      {
          get
          {
              return "This is a PowerShell snap-in that includes the Get-Proc cmdlet.";
          }
      }

      //Specify the localization resource information for the description.
      //Use the format: resourceBaseName,Description.
      public override string DescriptionResource
      {
          get
          {
              return "GetProcPSSnapIn,This is a PowerShell snap-in that includes the Get-Proc";
          }
      }
  }

Using the Windows Powershell snap-in library (.DLL file), register it to GAC using InstallUtil.exe. Remember that we need to sign our cmdlet assembly before register it to GAC. We can use PowerShell to set alias for InstallUtil.exe by the following:

PS > set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
PS > installutil SelectStrCommandSample.dll

Now we can add the Windows Powershell snap-in to the shell using the Add-PSSnapin cmdlet as shown below. Note : make sure you run the PowerShell using Administrator right.

PS > add-pssnapin GetProcPSSnapIn

To check the registration result, we can run:

PS > get-PSsnapin -registered

DONE

If the operation is successful, we should be able to run our cmdlet

PS > Get-Proc

DONE. Please download source code here. What about the MSMPI stuff??? Just to inform you as a closing, that PowerShell can use any Windows Objects (.NET, COM, WMI, etc). So MSMPI CMDLET should be possible! 


Hope this helps!

Ciao - RAM

Share this post: | | | |

Programming with PowerShell SDK | Part 1

In my previous posting, you may see many strange words, cmdlet (command let), provider, and hosting application. Those are the building blocks of PowerShell. To enable you writing them, you need PowerShell SDK. Windows® PowerShell SDK is part of the Microsoft Windows Software Development Kit for Windows Vista and .NET Framework 3.0 Runtime Components SDK.

ps01

Be aware that the Microsoft® Windows® PowerShell reference assemblies physically are downloaded onto disk (by default at C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0).They are not installed in the Global Assembly Cache (GAC).

ps03
If you go to GAC, you will find PowerShell assemblies as well.


02

Once you know where they are, you are ready to developer your first cmdlet, provider and hosting application. I will show you how to do that for simple cases in Part 2 (again, if I have enough spare time tonight). But the following MSDN articles will be helpful to build your understanding before writing codes. Let say, these are pre-requisites reading :) :

Conceptual
- How Windows PowerShell Works
- Windows PowerShell Programmer's Guide
- Windows PowerShell Object Concepts
- Extending Object Types and Formatting


How To Guidance
- How to Create a Windows PowerShell Cmdlet
- How to Create a Windows PowerShell Provider
- How to Create a Windows PowerShell Hosting Application
- How to Register Cmdlets, Providers, and Host Applications
- Cmdlet Development Guidelines

See you in MSDN Day !

Ciao - RAM

Share this post: | | | |

PowerShell - How It Works

It is important for Geeks to know how thing works before use it. Let me share with you little bit. After you installed PowerShell, check it out at:

Windows/System32/WindowsPowerShell/v1.0.

There are PowerShell.exe plus two DLLs (one for EventLog Message and the other for Crypto SIP). Many files with *.format and *.help extensions, of course for formatting and help description :). What is PowerShell? I profiled it to find its call tree. Let see:

ps08

The result is, PowerShell utilizes 3 additional DLLs on top of mscorwks.dll and BCRYPT.dll :

- Microsoft.PowerShell.ConsoleHost.ni.dll
- System.Management.Automation.ni.dll
- Microsoft.PowerShell.Commands.Utility.ni.dll


Those DLLs are core engine of PowerShell. PowerShell.exe itself is Windows PowerShell hosting application that exposes a command line to the user, and uses a host interface to communicate with the commands invoked by the command line. The hosting application can be a console application, a Windows application, or a Web application, some folks try to make PowerShell WPF Console or develop their own GUI/IDE like Open Source PowerGUI,  so it is completely extensible (click on image to download).

ps03   

In most cases, the hosting application uses its Main function to interact with the Windows PowerShell runtime through the internal host interface; however, a hosting application can optionally support its own custom host by implementing the PSHost class along with one or more related user interface classes. Together, these classes allow direct communication between the application and Windows PowerShell commands. A hosting application derives from PSHost class, overriding the abstract properties and required methods, and then passes an instance of its host class to the CreateRunspace method.

04 

Windows PowerShell runtime is the execution engine. The data retrieved and written by the runtime is in the form of data objects that are compatible with the .NET Framework. Windows PowerShell differs from other command based environments in that it uses objects to pass data through the pipeline. When passing objects through its pipeline, Windows PowerShell wraps each object in a PSObject object that is typically transparent to the user. We can also use the PSObject object to extend the members of objects. This feature, along with adapted views of object, is part of the Extended Type System (ETS) provided by Windows PowerShell. Let me explain ETS little bit more.

Windows PowerShell uses its PSObject object to extend the types of objects in two ways. First, the PSObject object provides a means to show different views of specific object types. This is referred to as showing an adapted view of an object. Second, by wrapping existing objects within the PSObject object, cmdlet and provider developers can add members to the base object. This allows you to manipulate any .NET object within the shell.

ps05   ps06

Invoked as a runspace, the Windows PowerShell runtime normally processes commands synchronously and delivers the results of processing to the hosting application, which then renders the results for the user. In this case, there is only the default interaction between the hosting application and the commands in a runspace. As I mentioned before, Windows PowerShell supports the execution scenario in which the hosting application implements its own custom host. In this case, the runspace is kept open and any number of commands can be run. The custom host can retrieve the results of processing either synchronously or asynchronously.

Windows PowerShell uses the Windows PowerShell provider infrastructure in the Windows PowerShell runtime to manage the Windows PowerShell providers. It normally starts the installed Windows PowerShell providers when it initializes the runspace and the corresponding session state, which tracks the providers in a global dictionary. The session state uses a path search mechanism to find all the *.cmdletprovider files reflected in the PSCOMMANDPATH and PATH environment variables.

ps07 

You can read more about that from this MSDN article. "How Thing Works" knowledge is really important when you want to extend PowerShell. I also suggest you to read PowerShell team blogs. A lot of information there, including new product ideas local ISVs :).

How To Get PowerShell and Its Documentations
- PowerShell 1.0 RTM
- PowerShell v2.0 CTP2
- PowerShell 1.0 Documentation Pack
- PowerShell 1.0 Quick Reference
- PowerShell Graphical Help File

Hope that helps!.

Ciao - RAM

Share this post: | | | |

MSDN Day with PowerShell

This is an invitation to all Geeks to attend Microsoft Developer Network event that will be held on Thursday, July 24, 2008. As always, this event is free, so you can take this as your free learning day every month!. My session is to help build and maintain momentum around PowerShell in a relation to Windows Client technologies, thats why Naren put a cozy "orchestrating" title on my session. 

PowerShell itself is not a big application. Some people think of it like a command line scripting language, such as Perl for example. But for me it depends to how you will use it. Let me give you a Hello Word PowerShell script here:

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$form = new-object Windows.Forms.Form
$form.Text = "Welcome to MSDN Day"
$button = new-object Windows.Forms.Button
$button.text="Push Me To Learn Powershell!"
$button.Dock="fill"
$button.add_click({$form.close()})
$form.controls.add($button)
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()

01

Note : I hope you can realize now how big is PowerShell but don't be panic!

Space is big. Really big. You just won’t believe how vastly hugely mind-bogglingly big it is. I mean you may think it’s a long way down the road to the "PowerShell", but that’s just peanuts compared to space. Don’t Panic!

— Modified from : Douglas Adams, The Hitchhiker’s Guide to the Galaxy

MSDN

So, I welcome you to MSDN Day! Come in, learn PowerShell, be creative, and, above all, have fun! To explore more, please read my articles to help you jump into deeper PowerShell exploration.

PowerShell - How it Works
Programming PowerShell SDK | Part 1
Programming PowerShell SDK | Part 2

Hope this helps! 

Ciao - RAM

Share this post: | | | |

Programming Multi-core | Part 2

The message-passing programming paradigm is one of the oldest and most widely used approaches for programming parallel computers. The famous MPI implementation is coming from Argonne National Laboratory. I am just downloaded MPICH2 (portable and high performance MPI API) it and want to share with you my first exploration. It is shipped with both Windows installer and source codes, so you can easily explore it. Please download here:

- MPICH2 - Installer
- MPICH2 - Source Codes
- MPICH2 - Documentation includes Windows Developer Guide

I strongly recommend MPICH2 from Argonne Lab, before you start to jump into Microsoft, HP or Intel implementations. First, because you have MPICH2 source codes to learn deeper, and second, because the codes are portable and came from the root of MPI. In this post, I will give you a quick start on how to compile and use MPICH2 API. I am using Vista SP1 in Intel Centrino Duo machine with Visual Studio C++ 2008 and Windows SDK installed.

1. Windows Binary Distribution
MPICH2 binary distribution uses the MS Installer. Please download and execute mpich2-1.x.xxx.msi to install the binary distribution. The default installation path is C:\Program Files\MPICH2. You must have administrator privileges to install mpich2-1.x.xxx.msi. The installer installs a Windows service to launch MPICH applications and only administrators may install services. This process manager is called smpd.exe. Access to the process manager is passphrase protected. The same passphrase must be installed on all nodes that will participate in a single MPI job.

02 

Under the installation directory are three important sub-directories: include, bin, and lib. The include and lib directories contain the header files and libraries necessary to compile MPI applications. The bin directory contains the process manager, smpd.exe, and the the MPI job launcher, mpiexec.exe. The dlls that implement MPICH2 are copied to the Windows system32 directory. The smpd process manager for Windows runs as a service that can launch jobs for multiple users. It does not need to be started like the *NIX version does. The service is automatically started when it is installed and when the machine reboots and it has additional options:

smpd -start            : Start the Windows smpd service.
smpd -stop             : Stop the Windows smpd service.
smpd -install          : Install the smpd service.
smpd -remove        : Remove the smpd service.
smpd -register spn : Register the Service Principal Name with the domain controller.

SPN command enables passwordless authentication using kerberos. It must be run on each node individually by a domain administrator.

3. Windows Source Distribution
To build MPICH2 from its source distribution on Windows, you will need Visual Studio 2005 or later and Perl. Once you extracted the source codes, please run script : winconfigure.wsf. You can remove FORTRAN if you dont have plan to use it by putting --remove-fortran option. Complete options of configuration are here:

03

If you want to compile the MPICH2 source codes using VC++ 2008 in Vista, there are some adjustment you have to do due to the change of vsprintf and sprintf. Do the following change to mpichconf.h :

#if not defined(_MSC_VER) || defined(__MINGW32__)
   #define snprintf _snprintf
   #define vsnprintf _vsnprintf
#endif


You will also get some error messages because VC++ 2008 can not find some header files. You can fix that by simply add include directories where the header files located. Once you can fix all the errors, you can easily compile MPICH2 source codes of 21 projects using VC++ 2008.

01 

3. Your First MPICH2 Program
You don't have to understand the whole MPICH2 source codes if you only want to use it for your computation. Source code level understanding is required if you want to extend or modify MPI implementation in MPICH2, let say, to match your deployment scenarios or to add more features. For MPICH2 users, what they need to care is the include header files (mpi.h) and library directories. Let start with the example program shipped with MPICH2 binary distribution:

#include "mpi.h"
#include <stdio.h>
#include <math.h>

double f(double);

double f(double a)
{
    return (4.0 / (1.0 + a*a));
}

int main(int argc,char *argv[])
{
    int done = 0, n, myid, numprocs, i;
    double PI25DT = 3.141592653589793238462643;
    double mypi, pi, h, sum, x;
    double startwtime = 0.0, endwtime;
    int  namelen;
    char processor_name[MPI_MAX_PROCESSOR_NAME];

    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
    MPI_Get_processor_name(processor_name,&namelen);

    /*
    fprintf(stdout,"Process %d of %d is on %s\n",
        myid, numprocs, processor_name);
    fflush(stdout);
    */

    while (!done) {
        if (myid == 0) {
            fprintf(stdout, "Enter the number of intervals: (0 quits) ");
        fflush(stdout);
            if (scanf("%d",&n) != 1) {
        fprintf( stdout, "No number entered; quitting\n" );
        n = 0;
        }
        startwtime = MPI_Wtime();
        }
        MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);
        if (n == 0)
            done = 1;
        else {
            h   = 1.0 / (double) n;
            sum = 0.0;
            for (i = myid + 1; i <= n; i += numprocs) {
                x = h * ((double)i - 0.5);
                sum += f(x);
            }
            mypi = h * sum;
            MPI_Reduce(&mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);

            if (myid == 0) {
                printf("pi is approximately %.16f, Error is %.16f\n",
                       pi, fabs(pi - PI25DT));
        endwtime = MPI_Wtime();
        printf("wall clock time = %f\n", endwtime-startwtime);          
        fflush( stdout );
        }
        }
    }
    MPI_Finalize();
    return 0;
}


To compile above codes in VC++ 2008, just make sure you have set the additional include and library link directories the project property of VC++ 2008. Then after compiled the codes, please run it with mpiexec.exe. Student can use VC++ 2008 Express Edition, which is free to download. I am waiting my new machine to be able to show how it really works. MPICH2 use WinSock for communication between processes. I hope you will not wait too long to see how it can be used for Numerical Computation and Computational Physic!

Hope this helps!


Ciao - RAM

Share this post: | | | |

SSCLI 2.0 with VC++ 2008 on Vista

I tried to compile SSCLI 2.0 with VC++ 2008 on Vista, and again, too many error messages, due to :

- Change of Windows Vista SDK include path and directory name
- SUBSYSTEM_WINVER = ,4.00 and SUBSYSTEM_CONVER = ,4.00 changed to ,5.00
- Incompatible warning level = -Wp64 (I am using 32 bit)
- Change of compiler (_MSC_VER ==1500) & runtime versions (_MSVCRT MSVCR90)

Basically you can do find and replace through all SSCLI source codes, but I strongly suggest you to follow Jeremy Kuhne manual steps. Once you done, just run env.bat and then buildall again. He also gives useful tips regarding the MSBUILD and VS Template for SSCLI.

Enjoy learning CLR through SSCLI Codes!

Ciao - RAM

Share this post: | | | |

LaTeX Equation Editor from CodeCogs

CodeCogs is an collaborative open-source library developed by community, with numerical components in C/C++ that can also be downloaded as Excel addins or used interactively through any website. CodeCogs goal is to create a well documented source of numerical solutions in all areas of engineering, computing, mathematics, science and finance. Great huh! I will spend time looking on their numerical library later on, but I want to share with you a cool thing, CodeCogs LaText Equation Editor.

01

Simple, first, please visit here, then try out the editor. Once you have done, test it with Render Equation button. You can copy the resulted HTML codes to your blogs. For example:

LaTeX                : \int_{0}^{10}\alpha \beta \gamma xdx
HTML Code        :

<a href="http://www.codecogs.com">
   <img src=
http://www.codecogs.com/gif.latex?\int_{0}^{10}\alpha&space;\beta&space;\gamma&space;xdx
            alt="\int_{0}^{10}\alpha \beta \gamma xdx" border="0"/>
</a>

Then put HTML code above into your Windows Live Writer (make sure you use HTML Mode). The result is:

\int_{0}^{10}\alpha \beta \gamma xdx 

CodeCogs LaTeX Equation editor can give you PDF, JPG, GIF, PNG and SWF format. Can anyone make it as Windows Live Write plug-in? Thats will be helpful.

Ciao - RAM

Share this post: | | | |

Weekend with Scientific Developer

I spent my weekend with my junior folks in Prof. Rosari Saleh research group. The problem was, I couldn't stop work if I have something cool (Geeks Syndrome). I just started my scientific blogs (RAM on Scientific Computing) and start working to coach my junior through KucingFisika.com and MIC-UI C++/Win32 Courses. Sagi and Wiria from Win32 Company was helping me much to encourage those scientific folks, and I am happy to let you know that "a new wave" is just started. We still have long journey to arrive at Parallel stuffs. Be patient!.

Below is the starting point :

- Welcome to KucingFisika
- Part 1. C++ /Win32 Programming at MIC-UI
- Additional C++ Texts for KucingFisika
- Mengintip Ke Luar Angkasa dengan WWT
- MPI.NET | Message Passing with C#
- Getting Numerical Recipes C++ Codes
- Numerical Recipes Tutorial - Part 1

Thats all for last week. See you this weekend with Scientific Computing. I possibly move my next lecture to Friday, July 18, 2008, because I will have vacation with family for Razka birthday (July 20, 2008).

Hope this helps!. 

Ciao - RAM

Share this post: | | | |

PHP is First-Class Citizen in Expression Web 2

For those who might wonder about how open Microsoft is to PHP community, here's one answer:

- PHP Extension for SQL Server 2005
- FastCGI Implementation in IIS 7.0
- SpikeSource ISV Inventory
- PHP Support in Expression Web version 2.

Rich set of features for PHP development in Expression Web Version 2. There are the expected productivity features such as code-coloring, snippets and IntelliSense™, but it doesn’t stop there. The product now ships with a PHP development server that lets you test your PHP pages without any other external web server dependencies (e.g. IIS or Apache). Essentially, PHP is now a first-class citizen in Expression Web 2, and will continue to be in upcoming versions of the product. Awesome!!! Click on image to know more.

 01

Hope this helps.


Regards, RAM

Share this post: | | | |

We are Hiring - Senior Consultants

These are senior level consultant positions for Microsoft Consultant Services. If you think, you are capable, please send your CV directly to (v-siyuan at microsoft dot com). Wish you luck !

Developer Senior Consultant
To provide leadership and guidance in the development and delivery of Microsoft solutions. The developer consultant will work directly with customers, partners and other Microsoft personnel to scope, design and build applications that utilize new and emergent technology

Responsibility:
Specific business metric results associated with this position include:

  • High Quality Solution Delivery: Development of solutions that are widely regarded as ‘best in class’.
  • Customer Satisfaction: Delivery of projects with a high level of engagement quality that results in high customer satisfaction metrics.
  • Knowledge sharing: Creation of intellectual property and knowledge sharing within and between practices.
  • Time Management: Management of billable time, training and holidays.
  • Project management of software development projects within commercial and time constraints, to customer and Microsoft satisfaction.

The focus of this position is the development of solutions that utilize new Microsoft technology, and helping others learn how to create similarly high quality solutions. This role will also lead the creation of case studies and references based on these solutions.

Requirements:

  • Highly proficient & solid Customer facing Project experience involving technical consulting, solution design, project envisioning, planning, development and deployment.
  • At least 8 years of related technology experience
  • Able to ascertain requirements, build specifications and design patterns to enable others to build solutions based on those designs.
  • Able to technically lead and mentor a small team during a project.
  • Excellent writing and documentation skills.
  • Excellent interpersonal and communication skills.
  • Strongly prefer official certifications associated with Microsoft Development and Database technologies.

SQL Senior Consultant
To deliver of high quality, leading edge consulting services based around Microsoft’s SQL Server technology. The focus of this role is on completing quality engagements that lead to improved customer satisfaction while achieving goals around personal development, knowledge sharing and utilization. With responsibility of Design, Vision and Scope, Strategy and Technical Documents, providing On-going Advice (Knowledge Transfer) to the Customer and Partners and Programming Code

Requirements:

  • Highly proficient & solid Customer facing Project experience involving technical consulting, solution design, project envisioning, planning, development and deployment.
  • At least 5 years of related technology experience
  • Strongly prefer official certifications associated with Microsoft Windows SQL Server 2000 and 2005 database applications and systems.
  • Candidates should have years of enterprise project experience in designing and implementing high performance OLTP solutions or building large data warehousing projects.
  • Able to ascertain requirements, build specifications and design patterns to enable others to build solutions based on those designs.
  • Able to technically lead and mentor a small team during a project.
  • Excellent writing and documentation skills.
  • Excellent interpersonal and communication skills.
  • Favoured Skills:
    • Microsoft Server Technologies, OS, SAN, MNS and multi-node Clustering, Biztalk
    • Network design and infrastructure
    • Security concepts, coding and infrastructure hardening expertise
    • Knowledge of DB2 or Oracle
    • Knowledge of SAP and achievement of Basis certification


Specific requirements for both positions include:

  • Excellent communication skills – written, verbal and presentation.
  • Customer credibility – a history of first hand experiences in project delivery to draw upon when talking with customers.
  • Working knowledge of business fundamentals in order to evaluate opportunities and sustain dialog with senior personnel within our customers.
  • Project management specific skills such as a working knowledge of earned-value analysis and managing multiple critical paths would be highly valued.

Ciao - RAM

Share this post: | | | |

C++/Win32 @ MIC UI - Course #1

This is the first time I will have students from Physics, Comp. Science and ISV (industry) all together. I believe each of them has their own background and thinking about what programming is all about. But with this diverse condition, will be challenging and also fun. :)

In Course #1, I will not cover all concerns from numerical to non-numerical computing, because it will be too broad. I will focus on the essential of computing with C++ in Windows, to give good foundation before writing C++ syntax (remember that codes are not executed in vacuum). I also will deliver this course with AlgoLAB spirit, providing clear WHY aspect before WHAT and HOW of computing. That will be fun too because I had observed that many students (and programmers) even from Comp. Science background did not fully understand how memory (for example) affected behaviors of their C and C++ programs.

To fill the gap between class-room contents and real world projects, AlgoLAB will offer 4 big projects for students to start working on:

- Advertising Gateway
- NextGen OS (Codename Belinda)
- PHP extension for Live (Codename PHP4Live)
- e-Science Community (Codename KucingFisika) : Silverlight based physics simulation.

Note:
- Involvement in projects is not mandatory. Only to make sure practice.
- Thanks to all sponsors : Microsoft Indonesia, Fasilkom UI, RTI, Kontinum and Prof. Rosari

Venue           : Ruang MIC, Gedung Fasilkom lt. 2, Kampus UI Depok
When             : 09.00 - 14.00, Saturday, July 12, 2008
Registration : Sagi Arsyad (sagia at live dot com)

C++ Foundation
- From Source to Executable File
- Type and Declaration
- Pointers, Address, Array and Structures

Win32 Foundation
- Win32 Error Handling
- Win32 Strings and Characters

Attention
- All participants will get C++ Developer Kits and all tools needed.
- Only 5 seats are available.
- Participants from ISV expected to bring their own laptop.
- This training is free of charge.

Hope this helps !.

Ciao, RAM

Share this post: | | | |

C++/Win32 at MIC University of Indonesia

I promised to Sagi sometime back to coach him on C++ and Win32. Unfortunately, I never have free time to spend with him for almost one year. I also had promise to Prof. Rosari Saleh, to help her research students getting in touch with C++ for numerical computing. With the same classical "time limited" reason, I can't make it until now. So sad!

But yesterday, in a small group discussion with all of them (5 from physics, 1 from computer science), I finally had courage to decide when we should start. Yes, we will run pilot C++/Win32 training to trainer (TTT) course at MIC University of Indonesia soon, code name AlgoLAB. Participants will come from Computer Science and Physic departments also from some local leading ISVs (3-5 persons).

My goals on this course is:
- Start C++/Win32 and Numerical Computing special interest group at MIC-UI
- Out reach scientific programmer with online community (e-Science?? Why not!)
- Create AlgoLAB C++ trainers from Physics and Computer Science Departments
- Get back to campus's atmosphere.... writing papers, will be fun for sure!

Fun fun and fun ! Indonesia e-Science community will be born from Prof. Rosari Saleh's LAB soon:

Kucing  Kucing2

Nico and Sagi are the external crew of KucingFisika (inspired by Schrodinger Cat). Thanks for them!

To support those goals, my course contents will cover:
- Part 1 : C++ Language aspects including C++ template and STL
- Part 2 : Basic Windows Programming with C++
- Part 3 : Numerical and Scientific computing with C++ (mandatory for physicist)
- Part 4 : Algorithm and data structure with C++ (mandatory for computer scientist)
- Part 5 : Multi-core stuffs (OpenMP, TBB, .NET Parallel Extension :)).

This course will be started on Saturday, July, 12, 2008. I plan to deliver it every saturday/sunday (3 hours per day) depends on my availability as I will have lot travels outside Indonesia next couple of months.

I will publish contents of all courses for all of you in Geeks.


Ciao - RAM

Share this post: | | | |

Composite Application Guidance with WPF

Finally, it is coming, CAB for WPF!!. Composite Application Guidance for WPF (CAG-WPF) will be helpful for you to build enterprise-level WPF client applications. To make your life easier to get in touch with it after download, Pattern and Practice team always give you:

- Getting Started Guide
- Reference Implementation : Stock Trader
- Quick Start Guide
- Hands On LAB

The CAG-WPF addresses a number of common requirements for building composite applications. Like previous CAB for Windows Form, the architecture the Composite Application Library seeks to address primarily consists of a shell application that defines regions for hosting content with views and services offered by multiple modules—possibly dynamically loaded. Underlying the application, and the CAG-WPF, is a service layer to provide access to the application services based on the Composite Application Library.

 04

With CAG-WPF, you can make client application richer and easy to maintain, like the included Stock Trader application from its distribution.

01

You will see how to use CAG-WPF in our next MSDN Day soon !


Ciao - RAM

Share this post: | | | |

My Current Reading

As work slowing down in July, I will have more time to finish my multi-core stuffs and trying it out with PLINQ, CCR and TBB :).

001 002 003008

Also need more 5 days to complete my PHP stuffs for incoming PHP4Live project:

004  005

Hope can continue my Multi-Core and PHP Extension articles.

See you - RAM

Share this post: | | | |