Using. NET remtoing for parallel computing

Source: Internet
Author: User
Tags config thread client
Using. NET remtoing Parallel Computing
In this paper, we analyze a program that uses the. NET romoting to compute the PI value in parallel,

and the results and performance analysis are given.



Found an article on MSDN that describes how to use the. NET remoting for parallel computations, just as I was interested in parallel computing, and then carefully analyzed the code for this program. The original text and procedures can be obtained here. Because I feel that the original text just made a general explanation, there are a lot of details just hidden in the source code, so spent a lot of time to analyze the source program, before the original has a very deep understanding, sparse cut out some content and share.



A Overview

. NET remtoing is used to invoke objects between remote servers and clients that exist in the same AppDomain. It uses SOAP or binary to deliver the message (that is, the object to invoke), and the delivery protocol is HTTP or TCP.



Two Remoting how do I implement parallel computing?

. NET Remoting and parallel computing seem to be two different concepts, which are more like distributed computing and Web Service, while the latter is actually a smaller-grained task, but it assigns a compute task to multiple node computations and then aggregates it back into one result.

According to the above ideas, the design of the distribution of the objects of the particle size can be realized in parallel computation. A key factor in parallel computing is communication between processes (or subtasks), and we can communicate between objects in the. NET Remoting as interprocess communication.

This example calculates PI's decimal point in parallel and is accurate to n-bit. Using. NET Remoting can be implemented as follows. Run the same program on each node, but each node calculates the decimal places in different locations, such as NodeA 1-9 digits after the decimal point, NodeB calculates 10-18 bits, NodeC calculates 19-27 digits, so the final rollup can have 1-27 digits. Because it is parallel computing, the time is many times faster than the single machine calculation, and its acceleration is related to the speed of each node and the speed of the entire communication network. The calculation model is shown in the following illustration:


Three Parallel algorithm

In order to carry out parallel computation, we must first design the parallel algorithm and the communication mode. Because we are only in the PC cluster parallel computing, so the simplest master-slave parallel model, that is, a main process responsible for the distribution of tasks, the result of the reduction of the average subtask assigned to each node calculation.

But in fact this article does not use the average assignment task, but rather the better task pool working mode. That is, after each node calculates a subtask, it will request a new task to the main process until the task is fully calculated, and the advantage is that the more compute-capable nodes compute the more tasks. Compared with the average distribution, it can improve the overall calculation and reduce synchronization time.






Four Program Structure

This program consists mainly of the following packages,


L 4. 1) ServerLoader

Used to load server objects that provide remote calls, specify the network protocols and ports used by the call, facilitate invocation on the LAN, and then listen for requests from clients, process the request on the server, and return the results.

In simple terms, each node must run the ServerLoader program to declare to the outside world the object that can be invoked (that is, the object in Plouffe_bellard.dll).



The following code is the calling configuration file:

String ConfigFilePath = Path.getdirectoryname (application.executablepath) + ServerLoader. Exe.config ";

RemotingConfiguration.Configure (ConfigFilePath);



Configuration file is: ServerLoader.exe.config

<configuration>

<system.runtime.remoting>

<application name = "ServerLoader" >

<service>

<wellknown

Mode= "SingleCall"

Type= "PB. Plouffe_bellard,plouffe_bellard "

objecturi= "Plouffe_Bellard"/>

</service>

<channels>

<channel ref= "TCP Server" port= "9000"/>

</channels>

</application>

</system.runtime.remoting>

</configuration>





L 4. 2) Plouffe_Bellard

This is the actual invoked remote object in the. NET remoting, which is placed on each node. It is inherited from System.MarshalByRefObject, so that the derived object never leaves its application domain, and the client can invoke the method of the remote object through the proxy object.

It is a program for calculating the decimal digits of Pi Pi, and the Plouffe_Bellard algorithm has a good parallelism that specifies the position of the decimal point to be computed, as described in section Ii.

The function form is:



public class Plouffe_Bellard:System.MarshalByRefObject

{

Public String calculatepidigits (int n)

{ ... }

}



L 4. 3) DIGITSOFPI

This is based on the core of the project and can be run as a client program. It mainly realizes the main interface UI processing, the node configuration, the multithread creation and the synchronization, the computation task assignment and the summary function, only then can run on any one node. Includes the following objects:

Mainform,solutionarray,solutionitem,remotingobject,calculationthread.

N mainform: Processing UI objects

n Solutionarray is a parallel thread allocation and management program, such as task pool creation, task assignment, thread creation, synchronization thread, converging results, and so on.

n Solutionitem is the data structure of the task. Includes the decimal point to compute, the result of the calculation, computed in the machine.

N Remotingobject is Remotepicalculator, which is used to get the remote object.

n calculationthread: Compute modules, which are generated and invoked by Solutionarray, and are continuously computed from the task pool.



The following is a sequence diagram of these objects:








When a remote object's calculatepidigits is called by a client program, this requirement is sent to the ServerLoader object of the remote machine. The object on the server then evaluates the result. Finally, the results of the calculation are returned to the client program, which is displayed in the text box.



Five Result analysis

machine configuration Instructions

MOORE 700MHz AMD Duron 192M SDR

Lozit 1.8GHz batumn 256M DDR

Time comparison




Because of the characteristics of the algorithm, you can see that the computational speed slows down when you calculate to a high position. On our machine, the speed of the near No. 3000 is already very slow, unable to endure the end of the interruption, calculated 3,330, a total of time-consuming 719545 MS, that is, 12 minutes. It was also found in the experiment that nodes can only be connected to other nodes in the same subnet, and that connecting to nodes outside the subnet may involve more advanced topics in. NET.



Six Postscript:

The parallel algorithm in this paper is relatively simple, and does not involve advanced algorithms and other content for parallel computing, such as no data transfer between subtasks. Is it appropriate to use. NET Remoting for parallel computing? When parallel communication libraries such as MPI,MVP are already available in the field of scientific computing? If MPI for C # can appear, that's a great gospel. (It's like the Russian experts have achieved the project, called T-system[2]). If there is time, I hope that in the future I will inherit research in the article with. NET Remoting for parallel computing. Some foreign research groups seem to have a lot to start this research, I hope that interested friends and I contact, discuss together.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.