![]() |
Blitz Support : |
From: Dalal, Navneet (navneet.dalal_at_[hidden])
Date: 2003-07-23 08:57:02
I tried this on gcc with -O3 and it works fine.
However, you may want to try this too:
template<typename T>
class Field
{
public:
Field(int M, int N) :dataArr(M,N)
{
dataArr = 0.34*blitz::tensor::i;
}
protected:
blitz::Array<T,2> dataArr;
};
> -----Original Message-----
> From: Einar Otnes [mailto:eiot_at_[hidden]]
> Sent: Wednesday, July 23, 2003 3:07 AM
> To: blitz-support_at_[hidden]
> Subject: [Blitz-support] Problems with SGI compiler and optimization
>
>
> 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
>