gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Open Cobol Optimization


From: Margit Schubert-While
Subject: [open-cobol-list] Open Cobol Optimization
Date: Sun Nov 16 08:17:23 2003

Keisuke asked me to post this info - so here it is.
Note - Applies to Linux

In an effort to get the same performance as MF, I noticed
that we are heavily bouncing in and out of the shared libs.
So I came up with this. "cobcrun" is a driver prog used to
call the Cobol prog. (This is equivalent to MF's "cobrun" and
ACU's "runcbl"). It pulls in the complete static versions of
libcob and libgmp. The difference in runtime performance
is astounding !
This also has a useful side effect in that
all Cobol progs can be compiled as modules. (And therefore
we do not need to work out which are main progs and which are
sub-progs for the compile)
(Note in cobcrun, that I move out argv0, otherwise we would
have to do some fancy checking for the command line accept)
(Note this is a quick and dirty, must do more checking)

In addition, with GCC > 3, you can tweak a bit more by passing
CFLAGS="-march=pentium3 -minline-all-stringops" (for P3 - arch=pentium4 for P4)
into the Open Cobol configure and also into the program compiles.

Here's cobcrun.c :
#include        <stdio.h>
extern void *cob_resolve (const char *name);
extern void cob_call_error (void);
int
main (int argc, char **argv)
{
        int ret;
        int (*func)();
        char    *argn[64];

        if ( argc <= 1 ) {
                fprintf(stderr, "No parameters specified\n");
                return 1;
        }
        for ( ret = 1; ret < argc; ret++ ) {
                argn[ret - 1] = argv[ret];
        }
        cob_init (argc - 1, argn);
        func = cob_resolve (argn[0]);
        if (func == NULL) {
                cob_call_error ();
        } else {
                ret = func ();
        }
        return ret;
}

And here's the compile/link for it :
gcc -rdynamic -Wl,-export-dynamic -O2 -o cobcrun \
cobcrun.c -Wl,-whole-archive /usr/local/lib/libcob.a \
/usr/lib/libgmp.a -Wl,-no-whole-archive -lltdl -ldb -lncurses -lm

Keisuke has indicated that something like this will be included in the next release.
Comments welcome.

Regards

Roger While




reply via email to

[Prev in Thread] Current Thread [Next in Thread]