Blitz logo

Blitz Support :

From: Julian Cummings (cummings_at_[hidden])
Date: 2003-07-24 15:16:45


Hello Einar,

I've been looking into this problem you reported. It appears to me that
the key
change in the compilation options is adding -DBZ_DEBUG, not switching from
optimization to debug flags. By just adding -DBZ_DEBUG to your set of
optimization compiler flags, you should see that your code works properly.

-DBZ_DEBUG mostly activates some Blitz assertions that are sprinkled
throughout
the code. I'm in the process of trying to narrow down what causes the
change in
behavior. It is probably something in the expression evaluator code.

Regards, Julian C.

Einar Otnes wrote:

>I am struggling using Blitz++-0.6 on the SGI 7.3.1.3m compiler using -O3
>optimization option. The code compiles fine, but the output results are
>just zero. When using the debugging option things are working fine. I have
>attached a simple program that exhibits this behaviour. Here, we get a
>problem with initializing the array which is zero after calling the init()
>routine. Is this a problem with the SGI compiler? Or am I doing something
>wrong?
>I have yet to try this example on the Intel Linux compiler.
>
>
> The program and the Makefile is listed below:
>
>Thanks
>Einar Otnes
>
>
>#include <iostream>
>#include <string>
>#include <blitz/array.h>
>
>namespace EPL
>{
>template<typename T>
> class Field
> {
> public:
>
> Field(int M, int N)
> {
> init(M,N);
> }
>
> protected:
>
> blitz::Array<T,2> dataArr;
>
>
> void init(int M, int N){
>
> // Initialize the array. Does not work when compiling with -O3.
>Sometimes this problem can be solved by
> // using for loops for initialization working on the array
>elementwise.
> dataArr.resize(M,N);
> dataArr = 0.34*blitz::tensor::i;
> }
>
> };
>
>
>template<typename T>
> class BnField : public Field<T>
> {
> public:
>
> BnField(int M, int N):Field<T>(M,N)
> {
> std::cerr << "Hello World!" << std::endl;
> }
>
> void multiplySelf(){
>
> T number(1,2);
> dataArr = number*dataArr;
> }
>
>
> void printAll(){
>
> std::cerr << "dataArr = " << dataArr << std::endl;
> }
>
> };
>
>
>} // End namespace EPL
>
>
>// Main program starts here
>
>using namespace EPL;
>
>int main(int argc, char *argv[])
>{
>
> int M = 4;
> int N = 5;
>
> BnField<std::complex<float> > B1(M,N);
>
> B1.printAll();
>
> B1.multiplySelf();
>
> B1.printAll();
>
> return EXIT_SUCCESS;
>}
>
>
>
>The Makefile with the two different CXXFLAGS is given below. The code works
>with the debugging option, but not without it.
>
>
>
># Path where Blitz++ is installed
>BZDIR = /private/eiot/Blitz++-0.6
>
>ARCH = mips64
>
>CXX = CC #-Bstatic
>
># Flags for optimized executables
>CXXFLAGS = -64 \
> -DBZ_DISABLE_XOPEN_SOURCE \
> -LANG:std -LANG:restrict \
> -I$(BZDIR)/include \
> -O3 -OPT:Olimit=0 -TENV:X=0 \
> -apo
>
>
>
># Flags for debugging
>#CXXFLAGS = -64 -g3 -DBZ_DEBUG \
># -DBZ_DISABLE_XOPEN_SOURCE \
># -LANG:std -LANG:restrict \
># -I$(BZDIR)/include \
># -apo
>
>
>LDFLAGS = -64 -lCio
>
>LIBS = -L$(BZDIR)/lib -lblitz \
> -lm -lCio \
> -apo
>
># Name of executable file
>EFILE = main
>
>OBJS = main.o
>
>main: $(OBJS)
> @echo "linking..."
> $(CXX) $(LDFLAGS) -o $(EFILE) $(OBJS) $(LIBS)
>
>$(OBJS): $(HDRS)
> $(CXX) $(CXXFLAGS) -c $*.cpp
>
>clean:
> rm -f $(OBJS) $(EFILE)
> rm -rf ii_files/
> rm -rf rii_files/
>
>main.o: main.cpp
>
>
>
>
>
>
>
>
>
>-------------------------------------------------------------------
>The information contained in this message may be CONFIDENTIAL and is
>intended for the addressee only. Any unauthorised use, dissemination of the
>information or copying of this message is prohibited. If you are not the
>addressee, please notify the sender immediately by return e-mail and delete
>this message.
>Thank you.
>
>
>_______________________________________________
>Blitz-support mailing list
>Blitz-support_at_[hidden]
>http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>
>

-- 
Dr. Julian C. Cummings                       E-mail: cummings_at_[hidden]
California Institute of Technology           Phone:  626-395-2543
1200 E. California Blvd., Mail Code 158-79   Fax:    626-584-5917
Pasadena, CA 91125