nathan binkert wrote:
I see one problem with this diff and a couple of nits.

1) What happens if physical memory is not a multiple of chunksize?
You don't actually deal with the tail end properly.  (As far as I
know, physical memory is only required to be a multiple of pagesize.)
My bad on this one. I was thinking that the gzwrite would only write to the size of the object like by a char array, but this assumption does not hold as it is not a c-string. My new diff is below, but I am unable to test it tonight due to some server issues at school:

diff --git a/src/mem/physical.cc b/src/mem/physical.cc
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -38,6 +38,7 @@

#include <iostream>
#include <string>
+#include <algorithm>

#include "arch/isa_traits.hh"
#include "base/misc.hh"
@@ -476,6 +477,7 @@
void
PhysicalMemory::serialize(ostream &os)
{
+    const unsigned int chunkSize = 16384;
    if (!pmemAddr)
        return;

@@ -496,12 +498,16 @@
    if (compressedMem == NULL)
        fatal("Insufficient memory to allocate compression state for %s\n",
                filename);
-
-    if (gzwrite(compressedMem, pmemAddr, params()->range.size()) !=
-        params()->range.size()) {
-        fatal("Write failed on physical memory checkpoint file '%s'\n",
-              filename);
-    }
+ + uint64_t curSize = 0;
+    do {
+ int unsigned chunkWriteSize = min((uint64_t)chunkSize, params()->range.size()-curSize); + unsigned int written_size = (unsigned int)gzwrite(compressedMem, pmemAddr + curSize, chunkWriteSize);
+        if (written_size <= 0) {
+ fatal("Write failed on physical memory checkpoint file '%s'\n",filename);
+        }
+        curSize += written_size;
+    } while (curSize < params()->range.size());

2) You left commented out code in the function.  The old code should
just be removed.
Fixed.
3) The indentation seems screwed up (though, that could be because of
the way you sent the diff).
Something weird maybe is going on with the mail, but I send it again the hope that it sends nicely.
I'd really appreciate it if you fixed these things, tested the code
and committed it.
I will test the code asap, and provide the diff now for anyone with a more functional system than I and a powerful need to get things running asap.
  Nate

On Thu, Jul 30, 2009 at 4:15 PM, Rick Strong<[email protected]> wrote:
I fixed a similar problem with the following diff:

diff --git a/src/mem/physical.cc b/src/mem/physical.cc
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -476,6 +476,7 @@
 void
 PhysicalMemory::serialize(ostream &os)
 {
+    const int chunkSize = 16384;
    if (!pmemAddr)
        return;

@@ -496,12 +497,20 @@
    if (compressedMem == NULL)
        fatal("Insufficient memory to allocate compression state for %s\n",
                filename);
-
-    if (gzwrite(compressedMem, pmemAddr, params()->range.size()) !=
-        params()->range.size()) {
+
+    /*if (written_size != params()->range.size()) {
        fatal("Write failed on physical memory checkpoint file '%s'\n",
              filename);
-    }
+    }*/
+
+    uint64_t curSize = 0;
+    do {
+        unsigned int written_size = (unsigned
int)gzwrite(compressedMem, pmemAddr + curSize, chunkSize);
+        if (written_size <= 0) {
+            fatal("Write failed on physical memory checkpoint file
'%s'\n",filename);
+        }
+        curSize += written_size;
+    } while (curSize < params()->range.size());

    if (gzclose(compressedMem))
        fatal("Close failed on physical memory checkpoint file '%s'\n",

William George Beazley Jr wrote:
Seems large than physical memory larger 1536MB suffers from:

Writing checkpoint
fatal: Write failed on physical memory checkpoint file
'system.physmem.physmem'
 @ cycle 500
[serialize:build/ALPHA_SE/mem/physical.cc, line 479]
Memory Usage: 5395972 KBytes

I should think this machine is large enough to support it:
[willi...@trout ~]$ free
             total       used       free     shared    buffers
cached
Mem:      66013472   17933008   48080464          0     284200
14918872
-/+ buffers/cache:    2729936   63283536
Swap:     78148152          0   78148152
[willi...@trout ~]$

-----------------------------------
Will Beazley|Sys. Software Analyst
409.880.7847|[email protected]
_______________________________________________
m5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/m5-users


_______________________________________________
m5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/m5-users




_______________________________________________
m5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/m5-users

Reply via email to