Use .NET RemToing to calculate parallel

zhaozj2021-02-16  39

Use the .NET RemToing parallel to calculate the summary, this article analyzes a program that uses .NET Romoting to calculate the PI value,

And give results and performance analysis.

Discover an article on the MSDN is how to use .NET Remoting parallel computing, I have just interested in parallel calculations, so I carefully analyze the code of this program. Original and procedures can be obtained here. Since I felt that the original text was just a rough explanation, there were many details just hidden in the source code, so after spending a lot of time to analyze the complete procedures, they have a deep understanding of the original text, and some contents come out and Everyone is shared.

One. Overview

.NET RemToing is used to call objects between remote servers and clients, which are existing in the same appdomain. It delivers messages using SOAP or binary ways (ie objects to be called), and the transfer protocol is HTTP or TCP.

two. How does REMOTIG implement parallel computing?

.NET Remoting and parallel computing seem to be two different concepts, the former is more similar to distributed computing and web service, and the latter is actually a task for calculating a smaller granularity, but it assigns a computing task to multiple nodes calculations. Then the summary makes a result to return. According to the above ideas, the particle size design of the distributed object can be implemented in parallel calculations. A key factor in parallel is a process (or sub-task) communication, and we can communicate between the objects between .NET Remoting as the process. This example is parallel to calculate the decimal point of the PI, 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 position of the different locations, such as 1-9 digits after the Nodea calculates the decimal point, NodeB calculates 10-18 bits, NODEC calculates 19-27 bits, so that the final summary results There can be 1-27 bits. Since it is parallel, the time is more than a single-machine calculation, and its acceleration is related to the speed of each node and the speed of the communication network. The calculation model is shown below:

three. Parallel algorithm

To perform parallel calculations, first design a parallel algorithm and communication mode. Since we are only in parallel in the PC group, the simplest master-slave parallel model is used, that is, the distribution of the main process is responsible for the mission, the result is constrained, and the subtask is allocated to each node. However, it is actually used in this article that is not average allocation task, but a better task pool. That is, after each node calculates a sub-task, the new task will be applied to the main process, and until all the tasks are all calculated, the more the benefits is the task of calculating the computing ability. The overall calculation and reduction of synchronization times are increased compared to average distribution.

four. Program structure

This procedure 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 in the call to facilitate calls in the local area network, then listen to the request from the client, handle this request on the server and return the result. Simply, each node must run the ServerLoader program to declare the object that can be called (the object in PLOUFFE_BELLARD.DLL).

The following code is called the configuration file:

String configfilepath = path.getdirectoryName (Application.executablePath) ServerLoader. EXE.CONFIG ";

RemotingConfiguration.configure (configfilepath); configuration file is: ServerLoader.exe.config

Wellknown

Mode = "SingleCall"

Type = "pb.plouffe_bellard, plouffe_bellard"

Objecturi = "plouffe_bellard" />

l 4.2) PLOUFFE_BELLARD

This is the actually called remote object in .NET Remoting, it is placed on each node. It is inherited from System.MarshalByrefObject, such derived objects never leave its application, and customers can call remote objects by proxy objects.

It is used to calculate the number of decimal points of the percentage PI, and the PLOUFFE_BELLARD algorithm has a good parallelism that specifies the position of the decimal point to calculate, as described in Section 2. Its function is:

Public class plouffe_bellard: system.marshalbyrefObject

{

Public String CalculatePidigits (int N)

{...}

}

l 4.3) DIGITSOFPI

On the basis of this, the core part of the entire project can be run as a client program. It mainly implements main interface UI processing, node configuration, multi-threaded creation and synchronization, computing task assignment, summary, only need to run on any of the nodes. Includes the following objects: Mainform, SolutionArray, SolutionItem, RemotingObject, Calculationthread.

n mainform: Treat UI object

n SolutionArray is a parallel thread allocation and management program, such as: task pool creation, task assignment, thread creation, synchronous thread, gathering results, etc.

N SolutionItem is the data structure of the task. Including the decimal point, calculated results, calculated in the machine.

n RemotingObject is RemotePicalCulator for obtaining a remote object.

n CalculationThread: Calculation module, calculates in the thread (generated by SolutionArray), and constantly obtains the task from the task pool.

The following is a sequence diagram of these objects:

This requirement is sent to the ServerLoader object of the remote machine when CalculatePIDIGIGITs of the remote object is called by the client program. Then the object on the server calculates the result. Finally, the calculated result is returned to the client program, displayed in the text box.

Fives. Result analysis

Machine configuration instructions Moore

700MHz AMD DURON 192M SDR

Lozit 1.8GHz Batumn 256M DDR

Time comparison

Due to the characteristics of the algorithm, it can be seen that the calculation speed gradually slows down. On our machine, it is already very slow, and it does not end up interruption. A total of 3,330 digits are calculated, and 719545 ms, that is, 12 minutes. In the experiment, it is found that the node can only be connected to other nodes in the same subnet, and to connect to the nodes outside the subnet, it is not clear that the higher level topic in .NET is not clear.

six. Postscript:

The parallel algorithm in this paper is relatively simple, and there is no advanced algorithm and other content involved in parallel calculations. If the data is not transmitted between the subtask. Is it possible to use .NET Remoting? When there is a parallel communication library such as MPI, MVP in the field of scientific calculations? If MPI for C # can appear, it is a great gospel. (It seems that Russia experts have realized this project called T-System [2]). If there is time, I hope to inherit the inheritance in my article in the future. Net Remoting is calculated in parallel. Some research groups in foreign countries seem to have a lot of research in this area, and hopeful friends and I will discuss them together.

Tuesday, April 20, 2004

Armylau2@163.com

references:

1. Parallel computing with .net remoting, Eric Bergman-Terrell

Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnhcvs03/html/vs03d1.asp

2. Alexander Chudinov, Vladimir Roganov, Parallel Computing Runtime for Microsoft .NET Framework

Wscg.zcu.cz/rotor/net_2003/papers/chudinov.pdf

转载请注明原文地址:https://www.9cbs.com/read-26315.html

New Post(0)