473,811 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read and write to files larger than 150mb with MPI?

14 New Member
Hi,
I am working on an MPI project using vb.net. If there is anyone in here that has experience using MPI.NET which is distributed by Indiana.edu please get back to me. I am having several unexplainable issues with this SDK and someone with experience migh have some tips that I could use.
I am particularly having issues working with large data files. The program that I am working on works fine with files upto 150MB but starts to fail with anything larger.
I am using Windows XP prof. and the system is a 1.8 Ghz with 1 GB of RAM.

The program i am writing simply reads a text file and then find the number of occurences of a "seaerchter m" in the file.

Thanks.
Rob

Here is the code:
Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
  2. Imports System.Threading.Tasks
  3. Imports System.Diagnostics
  4. Imports System.Text
  5. Imports System.Text.RegularExpressions
  6.  
  7.  
  8. Module Module1
  9.     Dim FS As FileStream
  10.     Dim comm As MPI.Intracommunicator
  11.     Dim AllocationSize As Long
  12.     Dim StartPos As Long
  13.     Dim EndPos As Long
  14.     Dim FileName As String
  15.     Dim FileSize As Long
  16.     Dim TextToRead As StringBuilder
  17.     Dim mode As String
  18.     Dim SearchTerm As String
  19.     Dim matchCount As Long = 0
  20.  
  21.  
  22.     Sub Main()
  23.  
  24.         Dim env As MPI.Environment = New MPI.Environment(Split(Command, " "))
  25.         comm = MPI.Communicator.world
  26.  
  27.         Dim sw As New Stopwatch
  28.         sw.Start()
  29.  
  30.         If Command() = "" Then
  31.             Console.WriteLine("Please enter a valid filename to be processed.")
  32.             Exit Sub
  33.         Else
  34.             Dim args As String() = Split(Command, ",")
  35.             FileName = args(0)
  36.             SearchTerm = args(1)
  37.         End If
  38.  
  39.         'read in the file to be processed
  40.         FS = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read)
  41.         FileSize = FS.Length
  42.  
  43.         If comm.Size > FileSize Then
  44.             Console.WriteLine("Quitting. Too many cooks spoil the broth.")
  45.             Exit Sub
  46.         End If
  47.         AllocationSize = Fix(FileSize / comm.Size)
  48.  
  49.         If comm.Rank = comm.Size - 1 Then
  50.  
  51.             StartPos = (comm.Rank * AllocationSize) + 1
  52.             EndPos = FileSize
  53.         Else
  54.             StartPos = (comm.Rank * AllocationSize) + 1
  55.             EndPos = (comm.Rank + 1) * AllocationSize
  56.         End If
  57.  
  58.         '______________________________________________________________
  59.         Dim br As New StreamReader(FS)
  60.         br.BaseStream.Seek(StartPos, SeekOrigin.Begin)
  61.         Dim WordLen As Integer = SearchTerm.Length - 1
  62.         Dim matches As Boolean = False
  63.         Dim posCounter As Long = StartPos
  64.         Dim i As Integer
  65.         Dim c As Integer
  66.         Console.WriteLine("TypeOf c is " & c.GetType.ToString)
  67.         Console.WriteLine("TypeOf i is " & i.GetType.ToString)
  68.         Console.WriteLine("TypeOf wordlen is " & WordLen.GetType.ToString)
  69.         Console.WriteLine("TypeOf ascw searchterm.char is " & AscW(SearchTerm.Chars(0)).GetType.ToString)
  70.  
  71.         Do  'br.Peek <> -1
  72.             c = br.Read
  73.             posCounter = posCounter + 1
  74.             If c = AscW(SearchTerm.Chars(0)) Then
  75.                 Console.Write("")
  76.                 matches = True
  77.                 For i = 1 To WordLen
  78.                     c = br.Read
  79.                     posCounter = posCounter + 1
  80.                     If c = AscW(SearchTerm.Chars(i)) Then 'And posCounter <= EndPos Then
  81.                         matches = True
  82.                     Else
  83.                         matches = False
  84.                         Exit For
  85.                     End If
  86.                 Next
  87.             Else
  88.                 matches = False
  89.             End If
  90.  
  91.             If matches = True Then
  92.                 matchCount += 1
  93.                 matches = False
  94.             End If
  95.  
  96.         Loop While posCounter <= EndPos
  97.  
  98.         Console.WriteLine(comm.Rank & " found: " & matchCount & " between " & StartPos & "->" & posCounter)
  99.         br.Close()
  100.         '______________________________________________________________
  101.  
  102.  
  103.  
  104.         'DoWordSearch()
  105.         'DoFileRead()
  106.         'DoFileWrite(TextToRead.ToString)
  107.         'Console.WriteLine("Worker {0} found {1} occurence.", comm.Rank, FindStringCount(TextToRead.ToString))
  108.  
  109.         Dim TotalMatches = comm.Reduce(Of Long)(matchCount, MPI.Operation(Of Long).Add, 0)
  110.         If comm.Rank = 0 Then
  111.             Console.WriteLine("Done Processing (MapReducing) and writing processed contents to \\{0}", MPI.Environment.ProcessorName & "\MPI\Output.txt")
  112.             Console.WriteLine("Total matches found - " & TotalMatches)
  113.         End If
  114.  
  115.         sw.Stop()
  116.         Dim MaxTime As Long = sw.ElapsedMilliseconds
  117.         Dim TimeToProcess As Long = comm.Reduce(Of Long)(MaxTime, MPI.Operation(Of Long).Max, 0)
  118.         If comm.Rank = 0 Then
  119.             Console.WriteLine()
  120.             Console.WriteLine("The parallel read and write operation tooka max of:{0} milliseconds with a file of size {1}", TimeToProcess, FileSize)
  121.             Console.WriteLine()
  122.         End If
  123.  
  124.         FS.Close()
  125.         comm = Nothing
  126.         env.Dispose()
  127.  
  128.     End Sub
  129.  
Jan 5 '11 #1
0 1034

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1115
by: eric cocozza | last post by:
Hi, I just moved a python program to a new server, and I'm getting path errors. It relys on the pear library and a image processing one. Please respond with cost based on 1/hr of work, and please accept paypal, or other simple form of payment. Thanks!
1
1343
by: clinton Brandt | last post by:
Hey I am Learning Blender for 3D mesh design and the current Relese doesnt recognize my python 2.4.1 it stopped at python 2.3. there alpha test of their next release supports py 2.4 but as a noob id like to learn an a less buggy release. so my question is can i install 2 versions of python and if i do, does the newer version hold rank when running .py files. or should i axe the version i have and the start with 2.3 then load 2.4 or what?...
2
1205
by: Vai2000 | last post by:
Hi All, To my correct understanding Garbage Collection works based on Generation algorithm...(high level). I have an application which does some heavy operations usually File I/O's. I want to force garbage collection on this class. I still want the GC to release all resources before finalizing etc...but I want GC to kick in ASAP, rather waiting to execute its algo to detect that this class needs cleaning up and finally come to its...
0
999
by: Carlos Fernandez | last post by:
Note: More evidence that the below scenario is a compiler bug is that it works when compiled as a static lib; it only fails as a .dll -------------------- Define a managed class with a method that takes a template parameter public __gc class UtilClass public UtilClass() void ConvertSomething( System::String *inString, NativeClass<int>&outType ); }
5
963
by: Jstone | last post by:
Hi all. I know this group is devoted to Javascript but I thought someone may be able to answer a couple questions for me. First, is there a way to customize the border of a Flash MX projector with Actionscript? By customize I mean to remove the border and add my own with my own buttons. I know there is software that will do it but they usually provide a gallery of border skins to choose from. I thought Swish Studio would let me design my...
2
1050
by: Guy Cohen | last post by:
Hi all. My webhost prepared a server for me with 2000 instead of 2005. Will my .net 2005 application work there? I generated a script to export my sql server 2005 object There was a failure here: IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'aspnet_WebEvent_FullAccess' AND type = 'R') CREATE ROLE
1
1117
by: frien | last post by:
I want to create a stored procedure to find if the index exists if not i have to create the index....i use following stored procedure....but does'nt seem to be working.......but when i hard code the query it does work... can u plz tell me were i am going wrong CREATE PROCEDURE . @tblName varchar(255), @colName varchar(255), @indName varchar(255) AS
3
993
by: =?Utf-8?B?ZG5vcnJpcw==?= | last post by:
Please let me know if I'm posting as an "MSDN subscrber"? I'm not getting responses to my posts for days. Thanks
2
5571
by: blogman | last post by:
I am getting a Visual studio 2008 IDE application R6034 runtime error. This means that the IDE application is raising the error not the application I am building. This means that Microsoft did not follow its own advice as listed in http://msdn.microsoft.com/en-us/library/ms235560(VS.80).aspx and "build with a manifest". The DLL in question seems to be msvcr8.0.dll which is the VS2005 C runtime DLL. I am not sure why this is an issue in a...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.