Forum > Windows

optimized sources

<< < (27/179) > >>

_heinz:
Merci Joe, thank you for your comment.
I use the source seti_boinc_2k3_2.2B1-Ben-Joe.7z from 02.03.2007. Hoping that it is stiil actual.
regards seti_britta ~heinz

_heinz:
@Simon
are there any changes in malloc_a.h since 2.2B source published ??
~heinz

Simon:
I don't think so, no.

Regards,
Simon.

_heinz:
The difficulties to compile malloc_a.h
----------------------------------------------------
1. to find the eror we copy the first lines from main.cpp into a new project named seti_start. We set the necessary include paths and can compile now.
here ist the short program:
---------------------------------------------------------------------------------------------------------------------------------------------------------------
// start_seti.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//
// Main program for command-line application.
// Usage: client [options]
//      -version show version info
//      -verbose print running status
//      -standalone
//      -bench
//      -show_benchmark

#include "stdafx.h"
#include "config.h"
    #include "boinc_win.h"
#include "diagnostics.h"
#include "util.h"
#include "s_util.h"
#include "boinc_api.h"
//#include "util.h"
//#include "s_util.h"
#include "analyze.h"
#include "analyzeFuncs.h"
#include "analyzePoT.h"
#include "worker.h"
#include "version.h"
#include "chirpfft.h"
#include "gaussfit.h"

#include "optimize.hpp"


// =======================================================================================
//    usage -
// =======================================================================================
void usage( void )
    {
    printf( "options:\n"
    #ifdef BOINC_APP_GRAPHICS
    " -nographics run without graphics\n"
    #endif
    " -version  show version info\n -verbose  print running status\n -standalone \n" );
    }

// =======================================================================================
//    print_error -
// =======================================================================================
void print_error( int e )
    {
    char    *p;
    p = error_string( e );
    fprintf( stderr, "%s\n", p );
    }

// =======================================================================================
//    print_version -
// =======================================================================================
void print_version( void )
    {
    printf( "SETI@home client.\nVersion: %d.%02d\n", gmajor_version, gminor_version );
    printf(
        "\nSETI@home is sponsored by individual donors around the world.\nIf you'd like to contribute to the project,\nplease visit the SETI@home web site at\nhttp://setiathome.ssl.berkeley.edu.\nThe project is also sponsored by the Planetary Society,\nthe University of California, Sun Microsystems, Paramount Pictures,\nFujifilm Computer Products, Informix, Engineering Design Team Inc,\nThe Santa Cruz Operation (SCO), Intel, Quantum Corporation,\nand the SETI Institute.\n\nSETI@home was developed by David Gedye (Founder),\nDavid Anderson (Director), Dan Werthimer (Chief Scientist),\nHiram Clawson, Jeff Cobb, Charlie Fenton,\nEric Heien, Eric Korpela, Matt Lebofsky,\nTetsuji 'Maverick' Rai and Rom Walton\n" );
    }

static int  g_argc;
static char **g_argv;
extern double           sigma_thresh;
extern double           f_PowerThresh;
extern double           f_PeakPowerThresh;
extern double           chi_sq_thresh;
bool                    nographics_flag;

int                     run_stage;
typedef seti_error      boinc_error;
extern APP_INIT_DATA    app_init_data;

//int _tmain(int argc, _TCHAR* argv[])
//{
int main( int argc, char **argv )
    {
    int retval = 0, i;
    FORCE_FRAME_POINTER;
    run_stage = PREGRX;
    g_argc = argc;

    if ( !(g_argv = ( char ** ) calloc( argc + 2, sizeof(char *) )) )
        {
        exit( MALLOC_FAILED );
        }

    setbuf( stdout, 0 );

    bool    standalone = false;
    #ifdef BOINC_APP_GRAPHICS
        nographics_flag = false;
    #else
        nographics_flag = true;
    #endif
   show_benchmark = false;
   g_argv[0] = argv[0];

    for ( i = 1; i < argc; i++ )
        {
        g_argv = argv;

        char    *p = argv;
        while ( *p == '-' ) p++;
        if ( !strncmp( p, "vers", 4 ) )
            {
            print_version();
            exit( 0 );
            }
        else if ( !strncmp( p, "verb", 4 ) )
            {
            verbose = 1;
            show_benchmark = true;
            }
        else if ( !strncmp( p, "st", 2 ) )
            {
            standalone = true;
            nographics_flag = true;
            }
        else if ( !strncmp( p, "no", 2 ) )
            {
            nographics_flag = true;
            }
        else if ( !strncmp( p, "bench", 5 ) )
            {
            show_benchmark = true;
            }
        else if ( !strncmp( p, "h", 1 ) )
            {
            usage();
            }
        }


   return 0;
}
------------------------------------------------------------------------------------------------------------



As you have seen bevore  there were 2 undefined variables, nitems, alignment. No problem, if we define it like this
      unsigned static int nitems, alignment;
We had todo this at the beginning in the class c_MEM. Here are the changed malloc_a.h
-------------------------------------------------------------------------------------------------------------------------

#if !defined( MALLOC_A_H )
#define MALLOC_A_H

#define MEM_ALIGN   64

#include "s_util.h"

void    * __fastcall malloc_a( size_t size, size_t alignment );
void    * __fastcall calloc_a( size_t size, size_t nitems, size_t alignment );
void    __fastcall free_a( void *palignedMem );

#if defined( USE_FFTWF )
   #include "fftw3.h"
   #define __OUR_MALLOC(size, align) fftwf_malloc( size )
   #define __OUR_FREE( ptr ) fftwf_free( ptr );
#elif defined( HAVE_MEMALIGN )
   #define __OUR_MALLOC(size, align) memalign( align, size )
   #define __OUR_FREE( ptr ) free( ptr );
#else
   #define __OUR_MALLOC(size, align) malloc_a( size, align )
   #define __OUR_FREE( ptr ) free_a( ptr );
#endif
class c_MEM {
   public:
      c_MEM() : used(0) {};
      ~c_MEM() {}   
      unsigned static int nitems, alignment; // seti_britta: new
      void *alloc( const char *name, size_t size, size_t alignment = MEM_ALIGN)
         {
         void *ptr = __OUR_MALLOC( size, alignment );
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
//         fprintf(stderr, "(%1.1fK) %s \n", size/1024.0, name);
         return ptr;
         };
//seti_britta:syntaxfehler:´Konstante´ -->konstanten in fkt-Aufrufen sind unzulässig !
      void *calloc( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
         {
         void *ptr = calloc_a( size, nitems, alignment );//error C2065: 'nitems': nichtdeklarierter Bezeichner, nitems, alignment
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
//         fprintf(stderr, "(%1.1fK) %s \n", size*nitems/1024.0, name);
         return ptr;
         };
      void *callocQ( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
         {
         void *ptr = calloc_a( size, nitems, alignment );
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
         return ptr;
         };
      //seti_britta: malloc_a.h(83) : error C2059: Syntaxfehler: 'Konstante'
      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };
//      void __fastcall free_a(void * ,1 );

      const char * __fastcall report( const char *name);
      int   used;
   };

// Create an actual structure to call based on
extern class c_MEM MEM;

#endif
--------------------------------------------------------------------------------------------------------------------------------------------------
If we compile now, we get:
Die Zwischen- und Ausgabedateien für das Projekt "start_seti" mit der Konfiguration "Debug|Win32" werden gelöscht.
Kompilieren...
stdafx.cpp
Kompilieren...
start_seti.cpp
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : warning C4002: Zu viele übergebene Parameter für das Makro 'calloc'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : error C2059: Syntaxfehler: 'Konstante'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(83) : error C2059: Syntaxfehler: 'Konstante'
Das Buildprotokoll wurde unter "file://c:\I\VS2005\Projects\start_seti\start_seti\Debug\BuildLog.htm" gespeichert.
start_seti - 2 Fehler, 1 Warnung(en)
--------------------------------------------------------------------------------------------------------------------------------------------------------------
the problems are

68       void *calloc( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
69         {
70         void *ptr = calloc_a( size, nitems, alignment );//error C2065: 'nitems': nichtdeklarierter Bezeichner, nitems, alignment
71         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
72//         fprintf(stderr, "(%1.1fK) %s \n", size*nitems/1024.0, name);
73         return ptr;
74         };
----------------------------------------------------
83      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };
----------------------------------------------------------------------------------------------------------------------------------------------
if we now goto 68 and look how calloc is declared we found in boinc_win.h --->
#define calloc(c, s)                          _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
if we now look how _calloc_dbg is declared we found a multideclaration(Mehrdeutigkeit) in two different files:
1. line 634 stdlib.h
_CRTIMP _CRT_JIT_INTRINSIC  _CRTNOALIAS _CRTRESTRICT __checkReturn __bcount_opt(_NumOfElements* _SizeOfElements)    void * __cdecl calloc(__in size_t _NumOfElements, __in size_t _SizeOfElements);

2. line 676 ff crtdbg.h
_CRTIMP __checkReturn __bcount_opt(_NumOfElements*_SizeOfElements) void * __cdecl _calloc_dbg(
        __in size_t _NumOfElements,
        __in size_t _SizeOfElements,
        __in int _BlockType,
        __in_z_opt const char * _Filename,
        __in int _LineNumber
        );
-----------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------
let´s now go to line 83 -->
83      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };
we look now where  __OUR_FREE is declared and found in malloc_a.h line 53 --->
53   #define __OUR_FREE( ptr ) free_a( ptr );
we go now where free_a is declared and found in line 43 malloc_a.h --->
43 void    __fastcall free_a( void *palignedMem );
we had todo now set into the macro to resolve it........

The multideclaration is the problem, any suggestions to solve it are welcome
regards seti_britta ~heinz

Josef W. Segur:
Overloaded functions are a feature of C and C++ so the compiler distinguishes between functions with the same name by the number and type of arguments. Name mangling distinguishes them in later parts of the compilation. There are fairly complex rules which allow for automatic conversion of types, and functions can actually be called with more arguments than shown in the declaration.

So, you are trying to do a DEBUG build and the overloaded calloc() definition in line 68 of malloc_a.h has the same number and type of arguments as the __calloc_dbg() which the boinc_win.h macro substitutes for calloc(). Conflict!

Crunch3r ran into the same thing when doing the Linux 2.2B builds so those sources have reverted all the MEM.calloc() etc. calls to calloc_a() etc. I think that's the best thing to do.
                                                                                      Joe

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version