- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Unix V4.0 1229 alpha , C programing 2 x array addr...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 05:04 AM
тАО01-12-2004 05:04 AM
Unix V4.0 1229 alpha , C programing 2 x array addressing
I've written a spam filter in C. When I port it
of to the alpha cluster it compiles fine but
core dumps while initializing a floating point
array which was dynamically allocated.
Size is 5466 x 5466.
The debuger tells me the SIGSEGV occured in
this function. line--> a[i][j] = .1;
It is called from
get_new_matrice(float **a,int size)
which creates a new 2 x matrice.
void
set_to_zero(float **a,int size)
{
int i,j;
for(i = 0;i < size;i++){
for(j = 0;j < size;j++){
a[i][j] = .1;
}
}
}
This code works on RedHat 9.0 and Windows XP.
Why a seg fault on such a basic operation.
How does the Unix "v4.0 1229 alpha" need to
coded to allow the array to be initialized,
or does the alpha unix addresses arrays
differently. I use calloc so everything is set
to zero, but must be reset to .1 .
Thanks for any help on this.
I attached the full code, matrices.c
Bob Hayward
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 05:31 AM
тАО01-12-2004 05:31 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
As a small logic test, perhaps try it with a much smaler matrix? 1000 x 1000 ?
I could not try here as you did not seem to have attached "matrices.h"
Maybe you experienced a simple ulimit problem? It is in the ballpark. For example on a box here I get:
> ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 131072
stack(kbytes) 8192
memory(kbytes) 4068040
coredump(blocks) unlimited
nofiles(descriptors) 4096
vmemory(kbytes) 4194304
The data component there is 131 MB which is right around 5466*5466 = 30 M floats no?
So check sysconfig to bump data into gig space?
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 06:18 AM
тАО01-12-2004 06:18 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
I once tried 450 x 450 with the same result.
Our help people don't think it is memory.
I don't think it is a bug or coding, how
else does one address an array in C.
Humm what does data 131072 kbytes
refer to if not ram memory since it is
1048576 kbytes.
Thanks for the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 06:59 AM
тАО01-12-2004 06:59 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
Thank your for your time. It turns out we have
a linux cluster RH 7.0 also and it runs on it. Still am curious, but is no longer an issue.
Take care,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 08:48 AM
тАО01-12-2004 08:48 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
Ah, I think I C it now...
You address the floats as if they were stored in flat address space: a[n][m] but you allocate n independend and not necesarily contiguous chuncks of m floats: *b[n]
I believe this violates C language as for example outlined in K&R 5.9 " Pointers vs. Multi-dimensional Arrays"1 (2nd edition)
If I am correct then you were very unfortunate to have this work at all. It may fail at any time on any platform. Had you worked on Tru64 from the get go, then you would have found your problem sooner. (You might get it to work 'accidently' on Tru64 by doing a large sbreak to make the malloc code request all required VM from the OS in one swoop.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 10:46 PM
тАО01-12-2004 10:46 PM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
allocating memory for an array of pointers but using the size of the data.
Have a look into your get_new_matrice() function. The line
a = (float**)calloc(size,sizeof(float));
should be
a = (float**)calloc(size,sizeof(float*));
because you are allocating memory for an array of pointers to additional memory and not for the values itself. This is also the reason why there was no problem on 32-bit machines.
Btw. compiling your program leads to definition problems of the prototypes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 01:59 AM
тАО01-13-2004 01:59 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
how I was allocating. I got the basic concept
off the web. So worked with it around with it
until the compiler to accepted it. Could fine
little documentation in the books on how to do
this.
http://www.eskimo.com/~scs/cclass/int/sx9b.html
Bob Hayward
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 02:52 AM
тАО01-13-2004 02:52 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
C for multiplatforms.
I'm pasted this one, but now am getting SIGFPE
using if(a[i][j] == ZERO) ZERO is 0.1E0.
My current C book only mentions the IEEE
floating point standards.
Thanks again,
Bob Hayward
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 07:32 PM
тАО01-13-2004 07:32 PM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
Btw. your allocation and zero mechanism is quite slow and not really "C"-like. Why not using pointers and offsets?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2004 02:23 AM
тАО01-14-2004 02:23 AM
Re: Unix V4.0 1229 alpha , C programing 2 x array addressing
we define zero as .1 to avoid divide by zero
errors when we compute the probabilities.
Thanks for the advice of the pointers and offsets. I'll check it out.