473,383 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

14
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 "seaerchterm" 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 1024

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

Similar topics

0
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...
1
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...
2
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...
0
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...
5
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...
2
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...
1
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...
3
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.