473,378 Members | 1,478 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,378 software developers and data experts.

handling large data

a
Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.

Nov 24 '07 #1
16 2747
a

"a" <a@a.comwrote in message news:fi**********@justice.itsc.cuhk.edu.hk...
Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.
Make error:

gcc -O3 -Wall -I. vote.c datamanager.c -o vote -L. -lhungarian
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/for instructions.
make: *** [vote] Error 1
Run-time (made in a supercomputer) error:
Segmentation fault
The program snippet:
int r[2000*2000]={
123,188,158,197,184,180,146,129,117,192,120,148,17 5,198,153,190,135,175,158,155,157,192,108,187,148, 187,199,139,158,120,174,168,184,162,132,191,166,11 3,167,148,131,159,107,120,164,115,115,110,117,105, 131,1
....};

Nov 24 '07 #2
a wrote:
"a" <a@a.comwrote in message news:fi**********@justice.itsc.cuhk.edu.hk...
>Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.

Make error:

gcc -O3 -Wall -I. vote.c datamanager.c -o vote -L. -lhungarian
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/for instructions.
make: *** [vote] Error 1
Maybe it ran out of space?
>
The program snippet:
int r[2000*2000]={
123,188,158,197,184,180,146,129,117,192,120,148,17 5,198,153,190,135,175,158,155,157,192,108,187,148, 187,199,139,158,120,174,168,184,162,132,191,166,11 3,167,148,131,159,107,120,164,115,115,110,117,105, 131,1
....};
Put the data in a files and read it in at runtime instead of using
static initialisation.

--
Ian Collins.
Nov 24 '07 #3
a wrote:
>
Would anybody please tell me how to handle array data of int 2000
* 2000? Even make file passes by using a supercomputer, it seems
calloc fails and segmentation fault results during a trial run.
Assuming you have a fairly normal system with sizeof int == 4, that
array requires 4,000,000 * 4, or 16 gigabytes of memory. Note that
the guaranteed available size is 65k (for C99) and 32k (for C90).
Many systems will give you 2 gigabytes, but only some 64 bit
systems will allow 16 gigs.

Look for another mechanism.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 24 '07 #4
CBFalconer wrote:
a wrote:
>Would anybody please tell me how to handle array data of int 2000
* 2000? Even make file passes by using a supercomputer, it seems
calloc fails and segmentation fault results during a trial run.

Assuming you have a fairly normal system with sizeof int == 4, that
array requires 4,000,000 * 4, or 16 gigabytes of memory.
s/giga/mega/ which leave a manageable answer, but maybe not for static
initialisation.

--
Ian Collins.
Nov 24 '07 #5
CBFalconer said:
a wrote:
>>
Would anybody please tell me how to handle array data of int 2000
* 2000? Even make file passes by using a supercomputer, it seems
calloc fails and segmentation fault results during a trial run.

Assuming you have a fairly normal system with sizeof int == 4, that
array requires 4,000,000 * 4, or 16 gigabytes of memory.
ITYM "megabytes", which isn't all *that* big really (although it's pretty
hefty for a local array).

One malloc for the row pointers, and one malloc per row, should do it
nicely on modern desktop systems with not too much else running.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 24 '07 #6
Richard Heathfield wrote:
CBFalconer said:
>a wrote:
>>>
Would anybody please tell me how to handle array data of int 2000
* 2000? Even make file passes by using a supercomputer, it seems
calloc fails and segmentation fault results during a trial run.

Assuming you have a fairly normal system with sizeof int == 4, that
array requires 4,000,000 * 4, or 16 gigabytes of memory.

ITYM "megabytes", which isn't all *that* big really (although it's
pretty hefty for a local array).

One malloc for the row pointers, and one malloc per row, should do
it nicely on modern desktop systems with not too much else running.
I keep doing that - missing a factor of 1000, or 10 cubed. Maybe I
need three less fingers. However, I did assume that he wanted a
single array, which is way over the minimum guarantee.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 24 '07 #7
CBFalconer wrote:
a wrote:
>Would anybody please tell me how to handle array data of int 2000
* 2000? Even make file passes by using a supercomputer, it seems
calloc fails and segmentation fault results during a trial run.

Assuming you have a fairly normal system with sizeof int == 4, that
array requires 4,000,000 * 4, or 16 gigabytes of memory. Note that
the guaranteed available size is 65k (for C99) and 32k (for C90).
Er, you mean megabytes. As such, the argument below is irrelevant.
Many systems will give you 2 gigabytes, but only some 64 bit
systems will allow 16 gigs.

Look for another mechanism.
Nov 24 '07 #8
Ian Collins wrote:
a wrote:
>"a" <a@a.comwrote in message news:fi**********@justice.itsc.cuhk.edu.hk...
>>Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.
Make error:

gcc -O3 -Wall -I. vote.c datamanager.c -o vote -L. -lhungarian
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/for instructions.
make: *** [vote] Error 1
Maybe it ran out of space?
Even if it does, it should fail cleanly rather than segfault.
Nov 24 '07 #9
In article <fi**********@justice.itsc.cuhk.edu.hk>, a <a@a.comwrote on
Saturday 24 Nov 2007 7:28 am:
Would anybody please tell me how to handle array data of int 2000 *
2000? Even make file passes by using a supercomputer, it seems calloc
fails and segmentation fault results during a trial run.
If you do not have sufficient primary storage the only option is to
operate on smaller chunks of the data. From the standpoint of Standard
C, you have no recourse upon a *alloc() failure, but to reduce the
requirements and try again. However a specific system may provide a
considerable amount of additional strategies and methods to cope with
large data.

With modern operating systems the system will do a lot of
behind-the-scenes work for you, so that often, you can simply do the
allocation and proceed. If however this does not work, you might try
memory-mapped files.

Nov 24 '07 #10
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
>
2000 * 2000 * int
ITYM "megabytes", which isn't all *that* big really (although it's pretty
hefty for a local array).

One malloc for the row pointers, and one malloc per row, should do it
nicely on modern desktop systems with not too much else running.
That's just a fairly normal sized image. How did we use to manage with
little 64k systems?

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Nov 24 '07 #11
In article <fi**********@justice.itsc.cuhk.edu.hk>, a <a@a.comwrote:
>Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.
If calloc() fails trying to allocate 2000*2000 ints, you almost
certainly have a system limit set too low. Ask your system
administrator how to change it (presumably you have a system
administrator if you have a supercomputer). You should of course be
checking for calloc() failing so that you don't get a segmentation
fault.

Or else there's some other bug in your program and it's nothing to do
with the amount of memory. To check for that possibility use a
program such as valgrind.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 24 '07 #12
a
it seems that big static *2D* array creates the problem, e.g.
a[1024][1024] but not a[1024*1024] makes the problem.

i try gcc -static to see if this helps but of no hope.

there will be too many modifications to take care when I switch to malloc or
related solutions. Is there any workaround?
Nov 24 '07 #13
a
Which file is to be changed? I also remember there should be a config file
to set many parameters...
"Richard Tobin" <ri*****@cogsci.ed.ac.ukwrote in message
news:fi***********@pc-news.cogsci.ed.ac.uk...
In article <fi**********@justice.itsc.cuhk.edu.hk>, a <a@a.comwrote:
>>Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.

If calloc() fails trying to allocate 2000*2000 ints, you almost
certainly have a system limit set too low. Ask your system
administrator how to change it (presumably you have a system
administrator if you have a supercomputer). You should of course be
checking for calloc() failing so that you don't get a segmentation
fault.

Or else there's some other bug in your program and it's nothing to do
with the amount of memory. To check for that possibility use a
program such as valgrind.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.

Nov 24 '07 #14
On 23 nov, 23:58, "a" <a...@a.comwrote:
Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.
If you're handling matrices, you may want study them use more
apropriate storage. Let's say, if you have a three diagonal matrix,
use 3 arrays for storage (it's going to make your code uglier, and
require more work - but it's gonna be really faster). Diagonal
matrices are fairly common from problems arising from finite
differences or finite elements. Allocating them as full matrices
usually is not worth it's price.

Vitor.
PS: I'm not a native speaker of english, so, pardon for my errors.
Nov 24 '07 #15
On Sat, 24 Nov 2007 22:32:37 +0800, "a" <a@a.comwrote:
>it seems that big static *2D* array creates the problem, e.g.
a[1024][1024] but not a[1024*1024] makes the problem.

i try gcc -static to see if this helps but of no hope.

there will be too many modifications to take care when I switch to malloc or
related solutions. Is there any workaround?
What is the actual type that size_t is a typedef for? What is the
maximum value for that type?

Since both a[1024][1024] and a[1024*1024] require the exact same
space, if one succeeds and the other fails then something else is
going on. A likely candidate is that SIZE_MAX is less than one
million and the multiplication in the latter declaration is wrapping
to some tolerable value. You should print the size of a in this case.

In any event, changing from a defined array to an allocated one
requires replacing only the one line declaration
int a[1024][1024];
with the small loop
int *a[1024];
for (i = 0; i < 1024; i++)
a[i] = malloc(1024 * sizeof *a[i]);
From then on, all references in your code to a[i][j] should remain
valid without modification.

Remove del for email
Nov 25 '07 #16
On Nov 24, 9:58 am, "a" <a...@a.comwrote:
Would anybody please tell me how to handle array data of int 2000 * 2000?
Even make file passes by using a supercomputer, it seems calloc fails and
segmentation fault results during a trial run.
Dec 8 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael | last post by:
Does anyone have any ideas about how I can go about this faster. I have a large form that is being submitted, and from that a new row in a database will be created. I'm working on the page that...
3
by: Wayne Marsh | last post by:
Hi all. I am working on an audio application which needs reasonably fast access to large amounts of data. For example, the program may load a 120 second stereo sound sample stored at 4bytes per...
14
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the...
6
by: WideBoy | last post by:
Hi I am wondering if someone has any ideas on how I might resolve the following problem. I have a large namespace file (1.5 MB) generated from a UML logical data model, which needless to say,...
3
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
9
by: Chad | last post by:
This might be a bit vague and poorly worded..... In my program, I handle function failures using fprintf() and exit() like: fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); There...
35
by: eliben | last post by:
Python provides a quite good and feature-complete exception handling mechanism for its programmers. This is good. But exceptions, like any complex construct, are difficult to use correctly,...
2
by: nguyenminhhai | last post by:
Hi everyone, I'm reading "The C++ Programming Language" (Bjarne Stroustrup, 3rd edition). At page 193, he said "Doing error handling using the same level of abstraction as the code that caused the...
2
by: MikeB | last post by:
Hi I hope that this is the correct place to post this question. I'm looking at developing an application which will enable me to import and process some data that is made available to me as...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.