<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_accessibility.hxx"
#include <accessibility/helper/characterattributeshelper.hxx>

using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;

// -----------------------------------------------------------------------------
// CharacterAttributesHelper
// -----------------------------------------------------------------------------

CharacterAttributesHelper::CharacterAttributesHelper( const Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor )
{
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackColor" )),     makeAny( (sal_Int32) nBackColor ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" )),         makeAny( (sal_Int32) nColor ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSet" )),   makeAny( (sal_Int16) rFont.GetCharSet() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontFamily" )),    makeAny( (sal_Int16) rFont.GetFamily() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" )),      makeAny( (::rtl::OUString) rFont.GetName() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontPitch" )),     makeAny( (sal_Int16) rFont.GetPitch() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontStyleName" )), makeAny( (::rtl::OUString) rFont.GetStyleName() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" )),        makeAny( (sal_Int16) rFont.GetSize().Height() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharScaleWidth" )),    makeAny( (sal_Int16) rFont.GetSize().Width() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" )),     makeAny( (sal_Int16) rFont.GetStrikeout() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" )),     makeAny( (sal_Int16) rFont.GetUnderline() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" )),        makeAny( (float) rFont.GetWeight() ) ) );
}

// -----------------------------------------------------------------------------

CharacterAttributesHelper::~CharacterAttributesHelper()
{
    m_aAttributeMap.clear();
}

// -----------------------------------------------------------------------------

Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes()
{
    Sequence< PropertyValue > aValues( m_aAttributeMap.size() );
    PropertyValue* pValues = aValues.getArray();

    for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++pValues )
    {
        pValues->Name   = aIt->first;
        pValues->Handle = (sal_Int32) -1;
        pValues->Value  = aIt->second;
        pValues->State  = PropertyState_DIRECT_VALUE;
    }

    return aValues;
}

// -----------------------------------------------------------------------------

Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const Sequence< ::rtl::OUString >& aRequestedAttributes )
{
    Sequence< PropertyValue > aValues;
    sal_Int32 nLength = aRequestedAttributes.getLength();

    if ( nLength != 0 )
    {
        const ::rtl::OUString* pNames = aRequestedAttributes.getConstArray();
        AttributeMap aAttributeMap;

        for ( sal_Int32 i = 0; i < nLength; ++i )
        {
            AttributeMap::iterator aFound = m_aAttributeMap.find( pNames[i] );
            if ( aFound != m_aAttributeMap.end() )
                aAttributeMap.insert( *aFound );
        }

        aValues.realloc( aAttributeMap.size() );
        PropertyValue* pValues = aValues.getArray();

        for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++pValues )
        {
            pValues->Name   = aIt->first;
            pValues->Handle = (sal_Int32) -1;
            pValues->Value  = aIt->second;
            pValues->State  = PropertyState_DIRECT_VALUE;
        }
    }
    else
    {
        aValues = GetCharacterAttributes();
    }

    return aValues;
}

// -----------------------------------------------------------------------------

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>Remove unnecessary comment lines<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_accessibility.hxx"
#include <accessibility/helper/characterattributeshelper.hxx>

using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;

CharacterAttributesHelper::CharacterAttributesHelper( const Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor )
{
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackColor" )),     makeAny( (sal_Int32) nBackColor ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" )),         makeAny( (sal_Int32) nColor ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSet" )),   makeAny( (sal_Int16) rFont.GetCharSet() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontFamily" )),    makeAny( (sal_Int16) rFont.GetFamily() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" )),      makeAny( (::rtl::OUString) rFont.GetName() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontPitch" )),     makeAny( (sal_Int16) rFont.GetPitch() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontStyleName" )), makeAny( (::rtl::OUString) rFont.GetStyleName() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" )),        makeAny( (sal_Int16) rFont.GetSize().Height() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharScaleWidth" )),    makeAny( (sal_Int16) rFont.GetSize().Width() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" )),     makeAny( (sal_Int16) rFont.GetStrikeout() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" )),     makeAny( (sal_Int16) rFont.GetUnderline() ) ) );
    m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" )),        makeAny( (float) rFont.GetWeight() ) ) );
}

CharacterAttributesHelper::~CharacterAttributesHelper()
{
    m_aAttributeMap.clear();
}

Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes()
{
    Sequence< PropertyValue > aValues( m_aAttributeMap.size() );
    PropertyValue* pValues = aValues.getArray();

    for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++pValues )
    {
        pValues->Name   = aIt->first;
        pValues->Handle = (sal_Int32) -1;
        pValues->Value  = aIt->second;
        pValues->State  = PropertyState_DIRECT_VALUE;
    }

    return aValues;
}

Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const Sequence< ::rtl::OUString >& aRequestedAttributes )
{
    Sequence< PropertyValue > aValues;
    sal_Int32 nLength = aRequestedAttributes.getLength();

    if ( nLength != 0 )
    {
        const ::rtl::OUString* pNames = aRequestedAttributes.getConstArray();
        AttributeMap aAttributeMap;

        for ( sal_Int32 i = 0; i < nLength; ++i )
        {
            AttributeMap::iterator aFound = m_aAttributeMap.find( pNames[i] );
            if ( aFound != m_aAttributeMap.end() )
                aAttributeMap.insert( *aFound );
        }

        aValues.realloc( aAttributeMap.size() );
        PropertyValue* pValues = aValues.getArray();

        for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++pValues )
        {
            pValues->Name   = aIt->first;
            pValues->Handle = (sal_Int32) -1;
            pValues->Value  = aIt->second;
            pValues->State  = PropertyState_DIRECT_VALUE;
        }
    }
    else
    {
        aValues = GetCharacterAttributes();
    }

    return aValues;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */<|endoftext|>


<commit_before>/* Copyright (c) FFLAS-FFPACK
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

//#include "goto-def.h"

#include "fflas-ffpack/fflas-ffpack-config.h"
#include <iostream>
#include <givaro/modular-balanced.h>

#include "fflas-ffpack/config-blas.h"
#include "fflas-ffpack/fflas/fflas.h"
#include "fflas-ffpack/utils/timer.h"
#include "fflas-ffpack/utils/args-parser.h"

#include "fflas-ffpack/utils/fflas_io.h"
#include "fflas-ffpack/utils/test-utils.h"

#include "fflas-ffpack/utils/timer.h"
#include "givaro/modular-integer.h"
#include "givaro/givcaster.h"

using namespace FFPACK;

using namespace std;
using namespace FFLAS;

template <typename Field>
struct need_field_characteristic { static constexpr bool value = false; };
template <typename Field>
struct need_field_characteristic<Givaro::Modular<Field>>{ static constexpr bool value = true; };
template <typename Field>
struct need_field_characteristic<Givaro::ModularBalanced<Field>>{ static constexpr bool value = true; };

template <typename Field>
struct compatible_data_type { static constexpr bool value = true; };
template <>
struct compatible_data_type<Givaro::ZRing<float>>{ static constexpr bool value = false; };
template <>
struct compatible_data_type<Givaro::ZRing<double>>{ static constexpr bool value = false; };

template <class Field, class RandIter, class Matrix, class Vector>
void fill_value(Field& F, RandIter& Rand,
    Matrix& A, Vector& X, Vector& Y,
    size_t m, size_t k, size_t incX, size_t incY, size_t lda, int NBK){

        // TODO: replace by a 1D pfrand
        PAR_BLOCK {

            SYNCH_GROUP(
                        FORBLOCK1D(iter, m, SPLITTER(NBK,
                        CuttingStrategy::Row, StrategyParameter::Threads
                        ),
                                   TASK(MODE(CONSTREFERENCE(F,Rand)),
                                        {
                                        frand(F, Rand,
                                              iter.end()-iter.begin(),
                                              k,
                                              A+iter.begin()*lda,
                                              lda);
                                        }
                                       );
                                  );
                       );
            //FFLAS::pfrand(F,Rand, m,k,A,m/NBK);
        }

    FFLAS::frand(F,Rand, k,1,X,incX);
    FFLAS::fzero(F, m,1,Y,incY);

}

template <class Field, class Matrix, class Vector>
void genData(Field& F,
    Matrix& A, Vector& X, Vector& Y,
    size_t m, size_t k, size_t incX, size_t incY, size_t lda, int NBK,
    int bitsize, uint64_t seed){

    typename Field::RandIter Rand(F,bitsize,seed);
    fill_value(F, Rand, A, X, Y, m, k, incX, incY, lda, NBK);
}

template <class Field, class Matrix, class Vector>
bool check_result(Field& F, size_t m, size_t lda, Matrix& A, Vector& X, size_t incX, Vector& Y, size_t incY){
    //Naive result checking by comparing result from pfgemv against the one from fgemv
    typename Field::Element_ptr Y2 = FFLAS::fflas_new(F,m,1);
    FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y2,  incY);

    for(size_t j=0; j<m; ++j){
        if(!F.areEqual(Y2[j],Y[j])){
            FFLAS::fflas_delete(Y2);
            return false;
        }
    }
    FFLAS::fflas_delete(Y2);
    return true;
}

template <class Field, class Matrix, class Vector>
bool benchmark_with_timer(Field& F, int p,
    Matrix& A, Vector& X, Vector& Y,
    size_t m, size_t k, size_t incX, size_t incY, size_t lda, size_t iters, int t, double& time){
    Timer chrono;
    bool pass = true;
    for (size_t i=0;i<=iters;++i){

        chrono.clear();

        if (p){

            typedef CuttingStrategy::Row row;
            typedef CuttingStrategy::Recursive rec;
            typedef StrategyParameter::Threads threads;
            typedef StrategyParameter::Grain grain;

            PAR_BLOCK{
                if (i) { chrono.start(); }

                switch (p){
                case 1:{
                           ParSeqHelper::Parallel<rec, threads>  H(t);
                           FFLAS::pfgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY, H);
                           break;}
                case 2:{
                           ParSeqHelper::Parallel<row, threads>  H(t);
                           FFLAS::pfgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY, H);
                           break;
                       }
                case 3:{
                           size_t BS = 64;
                           ParSeqHelper::Parallel<row, grain>  H(BS);
                           FFLAS::pfgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY, H);
                           break;
                       }
                default:{
                            FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY);
                            break;
                        }
                }
            }//PAR_BLOCK
            if (i) {chrono.stop(); time+=chrono.realtime();}
        }else{
            if (i) chrono.start();
            FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY);
            if (i) {chrono.stop(); time+=chrono.realtime();}
        }

        if(!check_result(F, m, lda,  A,  X, incX,  Y, incY)){
            pass = false;
            break;
        }

    }
    return pass;
}

template <class Field, class arg>
void benchmark_disp(Field& F, bool pass,
    double& time, size_t iters, int p,  size_t m, size_t k,
    arg& as){
    if(pass){
        std::cout << "Time: " << time / double(iters)
        << " Gflops: " << (2.*double(m)/1000.*double(k)/1000.0/1000.0) / time * double(iters);
        writeCommandString(std::cout, as) << std::endl;
    }else{
            std::cout<<"FAILED for "<<typeid(Field).name()<<std::endl;
            std::cout << "p:=" << p << ';'<<std::endl;
    }
}

template <class Field, class arg>
void benchmark_in_Field(Field& F, int p,  size_t m, size_t k,
    int NBK, int bitsize, uint64_t seed, size_t iters, int t,
    arg& as){

    double time=0.0;
    size_t lda,incX,incY;
    lda=k;
    incX=1;
    incY=1;
    typename Field::Element_ptr A,X,Y;

    A = FFLAS::fflas_new(F,m,lda);
    X = FFLAS::fflas_new(F,k,incX);
    Y = FFLAS::fflas_new(F,m,incY);

    genData(F, A, X, Y, m, k, incX, incY, lda, NBK, bitsize, seed);

    bool pass=benchmark_with_timer( F, p, A, X, Y, m, k, incX, incY, lda, iters, t, time);

    benchmark_disp(F, pass, time, iters, p, m, k, as);

    FFLAS::fflas_delete(A);
    FFLAS::fflas_delete(X);
    FFLAS::fflas_delete(Y);

}

template <class Field,  class arg >
void benchmark_with_field(int p,  size_t m, size_t k, int NBK, int bitsize, uint64_t seed, size_t iters, int t, arg& as){

    Field F;
    //static assert to raise compile time error for Non ZRing without providing a characteristic
    static_assert(!need_field_characteristic<Field>::value,
    "A field characteristic should be provided for Non ZRing data type !");
    //static assert to raise compile time error for ZRing with either float or double that could lead to inconsistent result
    static_assert(compatible_data_type<Field>::value,
    "The provided data type for ZRing is not compatible for the desired operation and could lead to inconsistent result !");

    benchmark_in_Field(F, p,  m, k, NBK, bitsize, seed, iters, t, as);

}

template <class Field, class arg>
void benchmark_with_field(const Givaro::Integer& q, int p,  size_t m, size_t k,
    int NBK, int bitsize, uint64_t seed, size_t iters, int t,
    arg& as){
    Field  F(q);
    benchmark_in_Field(F, p,  m, k, NBK, bitsize, seed, iters, t, as);
}

int main(int argc, char** argv) {

    int p=0;

    size_t iters = 10;
    Givaro::Integer q = 131071;
    size_t m = 800;
    size_t k = 800;

    uint64_t seed= getSeed();
    int t;
    PAR_BLOCK{
        t=NUM_THREADS;
    }
    int NBK = -1;
    int b=0;

    Argument as[] = {
        { 'q', "-q Q", "Set the field characteristic (-1 for random).",         TYPE_INTEGER , &q },
        { 'b', "-b B", "Set the bitsize of input.",         TYPE_INT , &b },
        { 'p', "-p P", "0 for sequential, 1 for <Recursive,Thread>, 2 for <Row,Thread>, 3 for <Row, Grain>.", TYPE_INT , &p },
        { 'm', "-m M", "Set the dimension m of the matrix.",                    TYPE_INT , &m },
        { 'k', "-k K", "Set the dimension k of the matrix.",                    TYPE_INT , &k },
        { 't', "-t T", "number of virtual threads to drive the partition.", TYPE_INT , &t },
        { 'N', "-n N", "number of numa blocks per dimension for the numa placement", TYPE_INT , &NBK },
        { 'i', "-i R", "Set number of repetitions.",                            TYPE_INT , &iters },
        { 's', "-s S", "Sets seed.",                            				TYPE_INT , &seed },
        END_OF_ARGUMENTS
    };

    parseArguments(argc,argv,as);

    if (NBK==-1) NBK = t;
    if(q==0){
        //benchmark_with_field<Givaro::ZRing<int32_t>>( p,  m, k, NBK, b, seed, iters, t, as);
        benchmark_with_field<Givaro::ZRing<Givaro::Integer>>( p,  m, k, NBK, b, seed, iters, t, as);
    }else{
        //benchmark_with_field<Givaro::Modular<float>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        //benchmark_with_field<Givaro::Modular<double>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        //benchmark_with_field<Givaro::Modular<int32_t>>(q, p,  m, k, NBK, b, seed, iters, t, as);

        //benchmark_with_field<Givaro::Modular<Givaro::Integer>>(q, p,  m, k, NBK, b, seed, iters, t, as);

        //benchmark_with_field<Givaro::ModularBalanced<float>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        benchmark_with_field<Givaro::ModularBalanced<double>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        //benchmark_with_field<Givaro::ModularBalanced<int32_t>>(q, p,  m, k, NBK, b, seed, iters, t, as);
    }

    return 0;
}
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
<commit_msg>space edit<commit_after>/* Copyright (c) FFLAS-FFPACK
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

//#include "goto-def.h"

#include "fflas-ffpack/fflas-ffpack-config.h"
#include <iostream>
#include <givaro/modular-balanced.h>

#include "fflas-ffpack/config-blas.h"
#include "fflas-ffpack/fflas/fflas.h"
#include "fflas-ffpack/utils/timer.h"
#include "fflas-ffpack/utils/args-parser.h"

#include "fflas-ffpack/utils/fflas_io.h"
#include "fflas-ffpack/utils/test-utils.h"

#include "fflas-ffpack/utils/timer.h"
#include "givaro/modular-integer.h"
#include "givaro/givcaster.h"

using namespace FFPACK;

using namespace std;
using namespace FFLAS;

template <typename Field>
struct need_field_characteristic { static constexpr bool value = false; };
template <typename Field>
struct need_field_characteristic<Givaro::Modular<Field>>{ static constexpr bool value = true; };
template <typename Field>
struct need_field_characteristic<Givaro::ModularBalanced<Field>>{ static constexpr bool value = true; };

template <typename Field>
struct compatible_data_type { static constexpr bool value = true; };
template <>
struct compatible_data_type<Givaro::ZRing<float>>{ static constexpr bool value = false; };
template <>
struct compatible_data_type<Givaro::ZRing<double>>{ static constexpr bool value = false; };

template <class Field, class RandIter, class Matrix, class Vector>
void fill_value(Field& F, RandIter& Rand,
    Matrix& A, Vector& X, Vector& Y,
    size_t m, size_t k, size_t incX, size_t incY, size_t lda, int NBK){

        // TODO: replace by a 1D pfrand
        PAR_BLOCK {

            SYNCH_GROUP(
                        FORBLOCK1D(iter, m, SPLITTER(NBK,
                        CuttingStrategy::Row, StrategyParameter::Threads
                        ),
                                   TASK(MODE(CONSTREFERENCE(F,Rand)),
                                        {frand(F, Rand, iter.end()-iter.begin(), k, A+iter.begin()*lda, lda);}
                                       );
                                  );
                       );
            //FFLAS::pfrand(F,Rand, m,k,A,m/NBK);
        }

    FFLAS::frand(F,Rand, k,1,X,incX);
    FFLAS::fzero(F, m,1,Y,incY);

}

template <class Field, class Matrix, class Vector>
void genData(Field& F,
    Matrix& A, Vector& X, Vector& Y,
    size_t m, size_t k, size_t incX, size_t incY, size_t lda, int NBK,
    int bitsize, uint64_t seed){

    typename Field::RandIter Rand(F,bitsize,seed);
    fill_value(F, Rand, A, X, Y, m, k, incX, incY, lda, NBK);
}

template <class Field, class Matrix, class Vector>
bool check_result(Field& F, size_t m, size_t lda, Matrix& A, Vector& X, size_t incX, Vector& Y, size_t incY){
    //Naive result checking by comparing result from pfgemv against the one from fgemv
    typename Field::Element_ptr Y2 = FFLAS::fflas_new(F,m,1);
    FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y2,  incY);

    for(size_t j=0; j<m; ++j){
        if(!F.areEqual(Y2[j],Y[j])){
            FFLAS::fflas_delete(Y2);
            return false;
        }
    }
    FFLAS::fflas_delete(Y2);
    return true;
}

template <class Field, class Matrix, class Vector>
bool benchmark_with_timer(Field& F, int p,
    Matrix& A, Vector& X, Vector& Y,
    size_t m, size_t k, size_t incX, size_t incY, size_t lda, size_t iters, int t, double& time){
    Timer chrono;
    bool pass = true;
    for (size_t i=0;i<=iters;++i){

        chrono.clear();

        if (p){

            typedef CuttingStrategy::Row row;
            typedef CuttingStrategy::Recursive rec;
            typedef StrategyParameter::Threads threads;
            typedef StrategyParameter::Grain grain;

            PAR_BLOCK{
                if (i) { chrono.start(); }

                switch (p){
                case 1:{
                           ParSeqHelper::Parallel<rec, threads>  H(t);
                           FFLAS::pfgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY, H);
                           break;}
                case 2:{
                           ParSeqHelper::Parallel<row, threads>  H(t);
                           FFLAS::pfgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY, H);
                           break;
                       }
                case 3:{
                           size_t BS = 64;
                           ParSeqHelper::Parallel<row, grain>  H(BS);
                           FFLAS::pfgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY, H);
                           break;
                       }
                default:{
                            FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY);
                            break;
                        }
                }
            }//PAR_BLOCK
            if (i) {chrono.stop(); time+=chrono.realtime();}
        }else{
            if (i) chrono.start();
            FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, lda, F.one, A, lda, X, incX, F.zero, Y,  incY);
            if (i) {chrono.stop(); time+=chrono.realtime();}
        }

        if(!check_result(F, m, lda,  A,  X, incX,  Y, incY)){
            pass = false;
            break;
        }

    }
    return pass;
}

template <class Field, class arg>
void benchmark_disp(Field& F, bool pass,
    double& time, size_t iters, int p,  size_t m, size_t k,
    arg& as){
    if(pass){
        std::cout << "Time: " << time / double(iters)
        << " Gflops: " << (2.*double(m)/1000.*double(k)/1000.0/1000.0) / time * double(iters);
        writeCommandString(std::cout, as) << std::endl;
    }else{
            std::cout<<"FAILED for "<<typeid(Field).name()<<std::endl;
            std::cout << "p:=" << p << ';'<<std::endl;
    }
}

template <class Field, class arg>
void benchmark_in_Field(Field& F, int p,  size_t m, size_t k,
    int NBK, int bitsize, uint64_t seed, size_t iters, int t,
    arg& as){

    double time=0.0;
    size_t lda,incX,incY;
    lda=k;
    incX=1;
    incY=1;
    typename Field::Element_ptr A,X,Y;

    A = FFLAS::fflas_new(F,m,lda);
    X = FFLAS::fflas_new(F,k,incX);
    Y = FFLAS::fflas_new(F,m,incY);

    genData(F, A, X, Y, m, k, incX, incY, lda, NBK, bitsize, seed);

    bool pass=benchmark_with_timer( F, p, A, X, Y, m, k, incX, incY, lda, iters, t, time);

    benchmark_disp(F, pass, time, iters, p, m, k, as);

    FFLAS::fflas_delete(A);
    FFLAS::fflas_delete(X);
    FFLAS::fflas_delete(Y);

}

template <class Field,  class arg >
void benchmark_with_field(int p,  size_t m, size_t k, int NBK, int bitsize, uint64_t seed, size_t iters, int t, arg& as){

    Field F;
    //static assert to raise compile time error for Non ZRing without providing a characteristic
    static_assert(!need_field_characteristic<Field>::value,
    "A field characteristic should be provided for Non ZRing data type !");
    //static assert to raise compile time error for ZRing with either float or double that could lead to inconsistent result
    static_assert(compatible_data_type<Field>::value,
    "The provided data type for ZRing is not compatible for the desired operation and could lead to inconsistent result !");

    benchmark_in_Field(F, p,  m, k, NBK, bitsize, seed, iters, t, as);

}

template <class Field, class arg>
void benchmark_with_field(const Givaro::Integer& q, int p,  size_t m, size_t k,
    int NBK, int bitsize, uint64_t seed, size_t iters, int t,
    arg& as){
    Field  F(q);
    benchmark_in_Field(F, p,  m, k, NBK, bitsize, seed, iters, t, as);
}

int main(int argc, char** argv) {

    int p=0;

    size_t iters = 10;
    Givaro::Integer q = 131071;
    size_t m = 800;
    size_t k = 800;

    uint64_t seed= getSeed();
    int t;
    PAR_BLOCK{
        t=NUM_THREADS;
    }
    int NBK = -1;
    int b=0;

    Argument as[] = {
        { 'q', "-q Q", "Set the field characteristic (-1 for random).",         TYPE_INTEGER , &q },
        { 'b', "-b B", "Set the bitsize of input.",                             TYPE_INT , &b },
        { 'p', "-p P", "0 for sequential, 1 for <Recursive,Thread>, 2 for <Row,Thread>, 3 for <Row, Grain>.", TYPE_INT , &p },
        { 'm', "-m M", "Set the dimension m of the matrix.",                    TYPE_INT , &m },
        { 'k', "-k K", "Set the dimension k of the matrix.",                    TYPE_INT , &k },
        { 't', "-t T", "number of virtual threads to drive the partition.",     TYPE_INT , &t },
        { 'N', "-n N", "number of numa blocks per dimension for the numa placement", TYPE_INT , &NBK },
        { 'i', "-i R", "Set number of repetitions.",                            TYPE_INT , &iters },
        { 's', "-s S", "Sets seed.",                                            TYPE_INT , &seed },
        END_OF_ARGUMENTS
    };

    parseArguments(argc,argv,as);

    if (NBK==-1) NBK = t;
    if(q==0){
        //benchmark_with_field<Givaro::ZRing<int32_t>>( p,  m, k, NBK, b, seed, iters, t, as);
        benchmark_with_field<Givaro::ZRing<Givaro::Integer>>( p,  m, k, NBK, b, seed, iters, t, as);
    }else{
        //benchmark_with_field<Givaro::Modular<float>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        //benchmark_with_field<Givaro::Modular<double>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        //benchmark_with_field<Givaro::Modular<int32_t>>(q, p,  m, k, NBK, b, seed, iters, t, as);

        //benchmark_with_field<Givaro::Modular<Givaro::Integer>>(q, p,  m, k, NBK, b, seed, iters, t, as);

        //benchmark_with_field<Givaro::ModularBalanced<float>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        benchmark_with_field<Givaro::ModularBalanced<double>>(q, p,  m, k, NBK, b, seed, iters, t, as);
        //benchmark_with_field<Givaro::ModularBalanced<int32_t>>(q, p,  m, k, NBK, b, seed, iters, t, as);
    }

    return 0;
}
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2012
 * Alessio Sclocco <a.sclocco@vu.nl>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <iostream>
#include <string>
#include <vector>
#include <exception>
#include <fstream>
#include <iomanip>
#include <limits>
#include <cmath>
#include <ctime>
using std::cout;
using std::cerr;
using std::endl;
using std::string;
using std::vector;
using std::exception;
using std::ofstream;
using std::fixed;
using std::setprecision;
using std::numeric_limits;

#include <ArgumentList.hpp>
#include <Observation.hpp>
#include <InitializeOpenCL.hpp>
#include <CLData.hpp>
#include <utils.hpp>
#include <Folding.hpp>
#include <FoldingCPU.hpp>
using isa::utils::ArgumentList;
using isa::utils::same;
using AstroData::Observation;
using isa::OpenCL::initializeOpenCL;
using isa::OpenCL::CLData;
using PulsarSearch::folding;
using PulsarSearch::Folding;

typedef float dataType;
const string typeName("float");
const unsigned int padding = 32;

// LOFAR
//const unsigned int nrSamplesPerSecond = 200000;
// Apertif
const unsigned int nrSamplesPerSecond = 20000;
// DMs
const unsigned int nrDMs = 256;
// Periods
const unsigned int nrPeriods = 128;
const unsigned int nrBins = 256;

int main(int argc, char *argv[]) {
	unsigned int clPlatformID = 0;
	unsigned int clDeviceID = 0;
	long long unsigned int wrongValues = 0;
	Observation< dataType > observation("FoldingTest", typeName);
	CLData< dataType > * dedispersedData = new CLData< dataType >("DedispersedData", true);
	CLData< dataType > * foldedData = new CLData<dataType >("FoldedData", true);
	CLData< unsigned int > * counterData = new CLData< unsigned int >("CounterData", true);

	try {
		ArgumentList args(argc, argv);

		clPlatformID = args.getSwitchArgument< unsigned int >("-opencl_platform");
		clDeviceID = args.getSwitchArgument< unsigned int >("-opencl_device");

	} catch ( exception &err ) {
		cerr << err.what() << endl;
		return 1;
	}

	// Setup of the observation
	observation.setPadding(padding);
	observation.setNrSamplesPerSecond(nrSamplesPerSecond);
	observation.setNrDMs(nrDMs);
	observation.setNrPeriods(nrPeriods);
	observation.setBasePeriod(nrBins);
	observation.setFirstPeriod(nrBins);
	observation.setPeriodStep(nrBins);
	observation.setNrBins(nrBins);

	cl::Context * clContext = new cl::Context();
	vector< cl::Platform > * clPlatforms = new vector< cl::Platform >();
	vector< cl::Device > * clDevices = new vector< cl::Device >();
	vector< vector< cl::CommandQueue > > * clQueues = new vector< vector < cl::CommandQueue > >();

	initializeOpenCL(clPlatformID, 1, clPlatforms, clContext, clDevices, clQueues);

	// Allocate memory
	dedispersedData->allocateHostData(observation.getNrSamplesPerSecond() * observation.getNrPaddedDMs());
	foldedData->allocateHostData(observation.getNrPaddedDMs() * observation.getNrBins() * observation.getNrPeriods());
	foldedData->blankHostData();
	counterData->allocateHostData(observation.getNrPaddedDMs() * observation.getNrBins() * observation.getNrPeriods());
	counterData->blankHostData();

	dedispersedData->setCLContext(clContext);
	dedispersedData->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));
	foldedData->setCLContext(clContext);
	foldedData->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));
	counterData->setCLContext(clContext);
	counterData->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));

	try {
		dedispersedData->allocateDeviceData();
		foldedData->allocateDeviceData();
		foldedData->copyHostToDevice();
		counterData->allocateDeviceData();
		counterData->copyHostToDevice();
	} catch ( OpenCLError err ) {
		cerr << err.what() << endl;
		return 1;
	}

	srand(time(NULL));
	for ( unsigned int sample = 0; sample < observation.getNrSamplesPerSecond(); sample++ ) {
		for ( unsigned int DM = 0; DM < observation.getNrDMs(); DM++ ) {
			dedispersedData->setHostDataItem((sample * observation.getNrPaddedDMs()) + DM, rand() % 100);
		}
	}

	// Test
	try {
		// Generate kernel
		Folding< dataType > clFold("clFold", typeName);
		clFold.bindOpenCL(clContext, &(clDevices->at(clDeviceID)), &((clQueues->at(clDeviceID)).at(0)));
		clFold.setObservation(&observation);
		clFold.setNrDMsPerBlock(128);
		clFold.setNrPeriodsPerBlock(2);
		clFold.setNrBinsPerBlock(1);
		clFold.setNrDMsPerThread(2);
		clFold.setNrPeriodsPerThread(2);
		clFold.setNrBinsPerThread(4);
		clFold.generateCode();

		dedispersedData->copyHostToDevice();
		clFold(dedispersedData, foldedData, counterData);
		foldedData->copyDeviceToHost();
	} catch ( OpenCLError err ) {
		cerr << err.what() << endl;
		return 1;
	}

	// Check
	CLData< dataType > * CPUFolded = new CLData<dataType >("CPUFolded", true);
	CLData< unsigned int > * CPUCounter = new CLData< unsigned int >("CPUCounter", true);
	CPUFolded->allocateHostData(observation.getNrBins() * observation.getNrPeriods() * observation.getNrPaddedDMs());
	CPUCounter->allocateHostData(observation.getNrBins() * observation.getNrPeriods() * observation.getNrPaddedDMs());
	folding(observation, dedispersedData->getHostData(), CPUFolded->getHostData(), CPUCounter->getHostData());
	for ( unsigned int bin = 0; bin < observation.getNrBins(); bin++ ) {
		long long unsigned int wrongValuesBin = 0;

		for ( unsigned int period = 0; period < observation.getNrPeriods(); period++ ) {
			for ( unsigned int DM = 0; DM < observation.getNrDMs(); DM++ ) {
				const unsigned int dataItem = (bin * observation.getNrPeriods() * observation.getNrPaddedDMs()) + (period * observation.getNrPaddedDMs()) + DM;
				if ( !same(CPUFolded->getHostDataItem(dataItem), foldedData->getHostDataItem(dataItem)) ) {
					wrongValues++;
					wrongValuesBin++;
				}
			}
		}

		if ( wrongValuesBin > 0 ) {
			cout << "Wrong samples bin " << bin << ": " << wrongValuesBin << " (" << (wrongValuesBin * 100) / (static_cast< long long unsigned int >(observation.getNrDMs()) * observation.getNrPeriods()) << "%)." << endl;
		}
	}

	cout << endl;
	cout << "Wrong samples: " << wrongValues << " (" << (wrongValues * 100) / (static_cast< long long unsigned int >(observation.getNrDMs()) * observation.getNrPeriods() * observation.getNrBins()) << "%)." << endl;
	cout << endl;

	return 0;
}

<commit_msg>The test has been updated to use the new samples per bin scheme.<commit_after>/*
 * Copyright (C) 2012
 * Alessio Sclocco <a.sclocco@vu.nl>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <iostream>
#include <string>
#include <vector>
#include <exception>
#include <fstream>
#include <iomanip>
#include <limits>
#include <cmath>
#include <ctime>
using std::cout;
using std::cerr;
using std::endl;
using std::string;
using std::vector;
using std::exception;
using std::ofstream;
using std::fixed;
using std::setprecision;
using std::numeric_limits;

#include <ArgumentList.hpp>
using isa::utils::ArgumentList;
#include <Observation.hpp>
using AstroData::Observation;
#include <InitializeOpenCL.hpp>
using isa::OpenCL::initializeOpenCL;
#include <CLData.hpp>
using isa::OpenCL::CLData;
#include <utils.hpp>
using isa::utils::same;
#include <Folding.hpp>
using PulsarSearch::Folding;
#include <FoldingCPU.hpp>
using PulsarSearch::folding;
#include <Bins.hpp>
using PulsarSearch::getNrSamplesPerBin;

typedef float dataType;
const string typeName("float");
const unsigned int padding = 32;

// LOFAR
//const unsigned int nrSamplesPerSecond = 200000;
// Apertif
const unsigned int nrSamplesPerSecond = 20000;
// DMs
const unsigned int nrDMs = 256;
// Periods
const unsigned int nrPeriods = 128;
const unsigned int nrBins = 256;

int main(int argc, char *argv[]) {
	unsigned int clPlatformID = 0;
	unsigned int clDeviceID = 0;
	long long unsigned int wrongValues = 0;
	Observation< dataType > observation("FoldingTest", typeName);
	CLData< dataType > * dedispersedData = new CLData< dataType >("DedispersedData", true);
	CLData< dataType > * foldedData = new CLData<dataType >("FoldedData", true);
	CLData< unsigned int > * counterData = new CLData< unsigned int >("CounterData", true);
	CLData< unsigned int > * nrSamplesPerBin = new CLData< unsigned int >("NrSamplesPerBin");

	try {
		ArgumentList args(argc, argv);

		clPlatformID = args.getSwitchArgument< unsigned int >("-opencl_platform");
		clDeviceID = args.getSwitchArgument< unsigned int >("-opencl_device");

	} catch ( exception &err ) {
		cerr << err.what() << endl;
		return 1;
	}

	// Setup of the observation
	observation.setPadding(padding);
	observation.setNrSamplesPerSecond(nrSamplesPerSecond);
	observation.setNrDMs(nrDMs);
	observation.setNrPeriods(nrPeriods);
	observation.setBasePeriod(nrBins);
	observation.setFirstPeriod(nrBins);
	observation.setPeriodStep(nrBins);
	observation.setNrBins(nrBins);

	cl::Context * clContext = new cl::Context();
	vector< cl::Platform > * clPlatforms = new vector< cl::Platform >();
	vector< cl::Device > * clDevices = new vector< cl::Device >();
	vector< vector< cl::CommandQueue > > * clQueues = new vector< vector < cl::CommandQueue > >();

	initializeOpenCL(clPlatformID, 1, clPlatforms, clContext, clDevices, clQueues);

	// Allocate memory
	dedispersedData->allocateHostData(observation.getNrSamplesPerSecond() * observation.getNrPaddedDMs());
	foldedData->allocateHostData(observation.getNrPaddedDMs() * observation.getNrBins() * observation.getNrPeriods());
	foldedData->blankHostData();
	counterData->allocateHostData(observation.getNrPaddedDMs() * observation.getNrBins() * observation.getNrPeriods());
	counterData->blankHostData();
	vector< unsigned int > * nrSamplesPerBinData = getNrSamplesPerBin(observation);
	nrSamplesPerBin->allocateHostData(*nrSamplesPerBinData);

	dedispersedData->setCLContext(clContext);
	dedispersedData->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));
	foldedData->setCLContext(clContext);
	foldedData->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));
	counterData->setCLContext(clContext);
	counterData->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));
	nrSamplesPerBin->setCLContext(clContext);
	nrSamplesPerBin->setCLQueue(&((clQueues->at(clDeviceID)).at(0)));

	try {
		dedispersedData->allocateDeviceData();
		foldedData->allocateDeviceData();
		foldedData->copyHostToDevice();
		counterData->allocateDeviceData();
		counterData->copyHostToDevice();
		NrSamplesPerBin->allocateDeviceData();
		nrSamplesPerBin->copyHostToDevice();
	} catch ( OpenCLError err ) {
		cerr << err.what() << endl;
		return 1;
	}

	srand(time(NULL));
	for ( unsigned int sample = 0; sample < observation.getNrSamplesPerSecond(); sample++ ) {
		for ( unsigned int DM = 0; DM < observation.getNrDMs(); DM++ ) {
			dedispersedData->setHostDataItem((sample * observation.getNrPaddedDMs()) + DM, rand() % 100);
		}
	}

	// Test
	try {
		// Generate kernel
		Folding< dataType > clFold("clFold", typeName);
		clFold.bindOpenCL(clContext, &(clDevices->at(clDeviceID)), &((clQueues->at(clDeviceID)).at(0)));
		clFold.setObservation(&observation);
		clFold.setNrSamplesPerBin(nrSamplesPerBin);
		clFold.setNrDMsPerBlock(128);
		clFold.setNrPeriodsPerBlock(2);
		clFold.setNrBinsPerBlock(1);
		clFold.setNrDMsPerThread(2);
		clFold.setNrPeriodsPerThread(2);
		clFold.setNrBinsPerThread(4);
		clFold.generateCode();

		dedispersedData->copyHostToDevice();
		clFold(dedispersedData, foldedData, counterData);
		foldedData->copyDeviceToHost();
	} catch ( OpenCLError err ) {
		cerr << err.what() << endl;
		return 1;
	}

	// Check
	CLData< dataType > * CPUFolded = new CLData<dataType >("CPUFolded", true);
	CLData< unsigned int > * CPUCounter = new CLData< unsigned int >("CPUCounter", true);
	CPUFolded->allocateHostData(observation.getNrBins() * observation.getNrPeriods() * observation.getNrPaddedDMs());
	CPUCounter->allocateHostData(observation.getNrBins() * observation.getNrPeriods() * observation.getNrPaddedDMs());
	folding(observation, dedispersedData->getHostData(), CPUFolded->getHostData(), CPUCounter->getHostData());
	for ( unsigned int bin = 0; bin < observation.getNrBins(); bin++ ) {
		long long unsigned int wrongValuesBin = 0;

		for ( unsigned int period = 0; period < observation.getNrPeriods(); period++ ) {
			for ( unsigned int DM = 0; DM < observation.getNrDMs(); DM++ ) {
				const unsigned int dataItem = (bin * observation.getNrPeriods() * observation.getNrPaddedDMs()) + (period * observation.getNrPaddedDMs()) + DM;
				if ( !same(CPUFolded->getHostDataItem(dataItem), foldedData->getHostDataItem(dataItem)) ) {
					wrongValues++;
					wrongValuesBin++;
				}
			}
		}

		if ( wrongValuesBin > 0 ) {
			cout << "Wrong samples bin " << bin << ": " << wrongValuesBin << " (" << (wrongValuesBin * 100) / (static_cast< long long unsigned int >(observation.getNrDMs()) * observation.getNrPeriods()) << "%)." << endl;
		}
	}

	cout << endl;
	cout << "Wrong samples: " << wrongValues << " (" << (wrongValues * 100) / (static_cast< long long unsigned int >(observation.getNrDMs()) * observation.getNrPeriods() * observation.getNrBins()) << "%)." << endl;
	cout << endl;

	return 0;
}

<|endoftext|>


<commit_before>/********** tell emacs we use -*- c++ -*- style comments *******************
 $Revision: 1.1 $  $Author: trey $  $Date: 2006-04-12 19:22:41 $

 @file    WRTDP.cc
 @brief   No brief

 Copyright (c) 2006, Trey Smith. All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:

 * The software may not be sold or incorporated into a commercial
   product without specific prior written permission.
 * The above copyright notice and this permission notice shall be
   included in all copies or substantial portions of the software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 ***************************************************************************/

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>

#include <iostream>
#include <fstream>
#include <queue>

#include "zmdpCommonDefs.h"
#include "zmdpCommonTime.h"
#include "MatrixUtils.h"
#include "Pomdp.h"
#include "WRTDP.h"

using namespace std;
using namespace sla;
using namespace MatrixUtils;

#define WRTDP_INIT_MAX_DEPTH (10)
#define WRTDP_MAX_DEPTH_ADJUST_RATIO (1.1)
#define WRTDP_IMPROVEMENT_CONSTANT (0.95)

namespace zmdp {

WRTDP::WRTDP(void)
{
  maxDepth = WRTDP_INIT_MAX_DEPTH;
}

void WRTDP::getMaxExcessUncOutcome(MDPNode& cn, int depth, WRTDPUpdateResult& r) const
{
  r.maxExcessUnc = -99e+20;
  r.maxExcessUncOutcome = -1;
  double width;
  MDPQEntry& Qa = cn.Q[r.maxUBAction];
  FOR (o, Qa.getNumOutcomes()) {
    MDPEdge* e = Qa.outcomes[o];
    if (NULL != e) {
      MDPNode& sn = *e->nextState;
      width = e->obsProb *
	(sn.ubVal - sn.lbVal - trialTargetPrecision * pow(problem->getDiscount(), depth+1));
      if (width > r.maxExcessUnc) {
	r.maxExcessUnc = width;
	r.maxExcessUncOutcome = o;
      }
#if 0
      printf("    a=%d o=%d obsProb=%g nslb=%g nsub=%g nsdiff=%g width=%g\n",
	     r.maxUBAction, o, e->obsProb, sn.lbVal, sn.ubVal, sn.ubVal - sn.lbVal, width);
#endif
    }
  }
}

void WRTDP::update(MDPNode& cn, int depth, WRTDPUpdateResult& r)
{
  double oldUBVal = cn.ubVal;
  bounds->update(cn, &r.maxUBAction);

  r.ubResidual = oldUBVal - r.maxUBVal;

  getMaxExcessUncOutcome(cn, depth, r);
}

void WRTDP::trialRecurse(MDPNode& cn, double logOcc, int depth)
{
  double excessUnc = cn.ubVal - cn.lbVal - trialTargetPrecision
    * pow(problem->getDiscount(), depth);

  if (excessUnc <= 0
#if USE_WRTDP_ADAPTIVE_DEPTH
      || depth > maxDepth
#endif
      ) {
#if USE_DEBUG_PRINT
    printf("  trialRecurse: depth=%d excessUnc=%g (terminating)\n",
	   depth, excessUnc);
    printf("  trialRecurse: s=%s\n", sparseRep(cn.s).c_str());
#endif

    return;
  }

  WRTDPUpdateResult r;
  update(cn, depth, r);

#if USE_WRTDP_ADAPTIVE_DEPTH
  double occ = (logOcc < -50) ? 0 : exp(logOcc);
  double updateQuality = r.ubResidual * occ;
  if (depth > oldMaxDepth) {
    oldQualitySum += updateQuality;
    oldNumUpdates++;
  } else {
    newQualitySum += updateQuality;
    newNumUpdates++;
  }
#endif

#if USE_DEBUG_PRINT
  printf("  trialRecurse: depth=%d [%g .. %g] a=%d o=%d\n",
	 depth, cn.lbVal, cn.ubVal, r.maxUBAction, r.maxExcessUncOutcome);
  printf("  trialRecurse: s=%s\n", sparseRep(cn.s).c_str());
#endif

  // recurse to successor
  assert(-1 != r.maxExcessUncOutcome);
  double obsProb = cn.Q[r.maxUBAction].outcomes[r.maxExcessUncOutcome]->obsProb;
  double weight = problem->getDiscount() * obsProb;
  double nextLogOcc = logOcc + log(weight);
  trialRecurse(cn.getNextState(r.maxUBAction, r.maxExcessUncOutcome),
	       nextLogOcc, depth+1);

  update(cn, depth, r);
}

bool WRTDP::doTrial(MDPNode& cn)
{
#if USE_DEBUG_PRINT
  printf("-*- doTrial: trial %d\n", (numTrials+1));
#endif

#if USE_WRTDP_ADAPTIVE_DEPTH
  oldQualitySum = 0;
  oldNumUpdates = 0;
  newQualitySum = 0;
  newNumUpdates = 0;
#endif

  trialTargetPrecision = (cn.ubVal - cn.lbVal) * WRTDP_IMPROVEMENT_CONSTANT;

  trialRecurse(cn,
	       /* logOcc = */ log(1.0),
	       /* depth = */ 0);

#if USE_WRTDP_ADAPTIVE_DEPTH
  double updateQualityRatio;
  if (0 == oldQualitySum) {
    updateQualityRatio = 1000;
  } else if (0 == newNumUpdates) {
    updateQualityRatio = 0;
  } else {
    double oldMean = oldQualitySum / oldNumUpdates;
    double newMean = newQualitySum / newNumUpdates;
    updateQualityRatio = newMean / oldMean;
  }

  if (updateQualityRatio >= 1.0) {
    oldMaxDepth = maxDepth;
    maxDepth *= WRTDP_MAX_DEPTH_ADJUST_RATIO;
#if USE_DEBUG_PRINT
    printf("endTrial: updateQualityRatio=%g oldMaxDepth=%g maxDepth=%g\n",
	   updateQualityRatio, oldMaxDepth, maxDepth);
#endif
  } else {
#if USE_DEBUG_PRINT
  printf("endTrial: updateQualityRatio=%g maxDepth=%g (no change)\n",
	 updateQualityRatio, maxDepth);
#endif
  }
#endif // if USE_WRTDP_ADAPTIVE_DEPTH

  numTrials++;

  return (cn.ubVal - cn.lbVal < targetPrecision);
}

}; // namespace zmdp

/***************************************************************************
 * REVISION HISTORY:
 * $Log: not supported by cvs2svn $
 *
 ***************************************************************************/
<commit_msg>fixed sign error in excess uncertainty calculation; fixed some code to properly be inside a #if USE_WRTDP_ADAPTIVE_DEPTH block<commit_after>/********** tell emacs we use -*- c++ -*- style comments *******************
 $Revision: 1.2 $  $Author: trey $  $Date: 2006-04-12 19:48:47 $

 @file    WRTDP.cc
 @brief   No brief

 Copyright (c) 2006, Trey Smith. All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:

 * The software may not be sold or incorporated into a commercial
   product without specific prior written permission.
 * The above copyright notice and this permission notice shall be
   included in all copies or substantial portions of the software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 ***************************************************************************/

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>

#include <iostream>
#include <fstream>
#include <queue>

#include "zmdpCommonDefs.h"
#include "zmdpCommonTime.h"
#include "MatrixUtils.h"
#include "Pomdp.h"
#include "WRTDP.h"

using namespace std;
using namespace sla;
using namespace MatrixUtils;

#define WRTDP_INIT_MAX_DEPTH (10)
#define WRTDP_MAX_DEPTH_ADJUST_RATIO (1.1)
#define WRTDP_IMPROVEMENT_CONSTANT (0.95)

namespace zmdp {

WRTDP::WRTDP(void)
{
#if USE_WRTDP_ADAPTIVE_DEPTH
  maxDepth = WRTDP_INIT_MAX_DEPTH;
#endif
}

void WRTDP::getMaxExcessUncOutcome(MDPNode& cn, int depth, WRTDPUpdateResult& r) const
{
  r.maxExcessUnc = -99e+20;
  r.maxExcessUncOutcome = -1;
  double width;
  MDPQEntry& Qa = cn.Q[r.maxUBAction];
  FOR (o, Qa.getNumOutcomes()) {
    MDPEdge* e = Qa.outcomes[o];
    if (NULL != e) {
      MDPNode& sn = *e->nextState;
      width = e->obsProb *
	(sn.ubVal - sn.lbVal - trialTargetPrecision * pow(problem->getDiscount(), -(depth+1)));
      if (width > r.maxExcessUnc) {
	r.maxExcessUnc = width;
	r.maxExcessUncOutcome = o;
      }
#if 0
      printf("    a=%d o=%d obsProb=%g nslb=%g nsub=%g nsdiff=%g width=%g\n",
	     r.maxUBAction, o, e->obsProb, sn.lbVal, sn.ubVal, sn.ubVal - sn.lbVal, width);
#endif
    }
  }
}

void WRTDP::update(MDPNode& cn, int depth, WRTDPUpdateResult& r)
{
  double oldUBVal = cn.ubVal;
  bounds->update(cn, &r.maxUBAction);

  r.ubResidual = oldUBVal - r.maxUBVal;

  getMaxExcessUncOutcome(cn, depth, r);
}

void WRTDP::trialRecurse(MDPNode& cn, double logOcc, int depth)
{
  double excessUnc = cn.ubVal - cn.lbVal - trialTargetPrecision
    * pow(problem->getDiscount(), -depth);

  if (excessUnc <= 0
#if USE_WRTDP_ADAPTIVE_DEPTH
      || depth > maxDepth
#endif
      ) {
#if USE_DEBUG_PRINT
    printf("  trialRecurse: depth=%d excessUnc=%g (terminating)\n",
	   depth, excessUnc);
    printf("  trialRecurse: s=%s\n", sparseRep(cn.s).c_str());
#endif

    return;
  }

  WRTDPUpdateResult r;
  update(cn, depth, r);

#if USE_WRTDP_ADAPTIVE_DEPTH
  double occ = (logOcc < -50) ? 0 : exp(logOcc);
  double updateQuality = r.ubResidual * occ;
  if (depth > oldMaxDepth) {
    oldQualitySum += updateQuality;
    oldNumUpdates++;
  } else {
    newQualitySum += updateQuality;
    newNumUpdates++;
  }
#endif

#if USE_DEBUG_PRINT
  printf("  trialRecurse: depth=%d [%g .. %g] a=%d o=%d\n",
	 depth, cn.lbVal, cn.ubVal, r.maxUBAction, r.maxExcessUncOutcome);
  printf("  trialRecurse: s=%s\n", sparseRep(cn.s).c_str());
#endif

  // recurse to successor
  assert(-1 != r.maxExcessUncOutcome);
  double obsProb = cn.Q[r.maxUBAction].outcomes[r.maxExcessUncOutcome]->obsProb;
  double weight = problem->getDiscount() * obsProb;
  double nextLogOcc = logOcc + log(weight);
  trialRecurse(cn.getNextState(r.maxUBAction, r.maxExcessUncOutcome),
	       nextLogOcc, depth+1);

  update(cn, depth, r);
}

bool WRTDP::doTrial(MDPNode& cn)
{
#if USE_DEBUG_PRINT
  printf("-*- doTrial: trial %d\n", (numTrials+1));
#endif

#if USE_WRTDP_ADAPTIVE_DEPTH
  oldQualitySum = 0;
  oldNumUpdates = 0;
  newQualitySum = 0;
  newNumUpdates = 0;
#endif

  trialTargetPrecision = (cn.ubVal - cn.lbVal) * WRTDP_IMPROVEMENT_CONSTANT;

  trialRecurse(cn,
	       /* logOcc = */ log(1.0),
	       /* depth = */ 0);

#if USE_WRTDP_ADAPTIVE_DEPTH
  double updateQualityRatio;
  if (0 == oldQualitySum) {
    updateQualityRatio = 1000;
  } else if (0 == newNumUpdates) {
    updateQualityRatio = 0;
  } else {
    double oldMean = oldQualitySum / oldNumUpdates;
    double newMean = newQualitySum / newNumUpdates;
    updateQualityRatio = newMean / oldMean;
  }

  if (updateQualityRatio >= 1.0) {
    oldMaxDepth = maxDepth;
    maxDepth *= WRTDP_MAX_DEPTH_ADJUST_RATIO;
#if USE_DEBUG_PRINT
    printf("endTrial: updateQualityRatio=%g oldMaxDepth=%g maxDepth=%g\n",
	   updateQualityRatio, oldMaxDepth, maxDepth);
#endif
  } else {
#if USE_DEBUG_PRINT
  printf("endTrial: updateQualityRatio=%g maxDepth=%g (no change)\n",
	 updateQualityRatio, maxDepth);
#endif
  }
#endif // if USE_WRTDP_ADAPTIVE_DEPTH

  numTrials++;

  return (cn.ubVal - cn.lbVal < targetPrecision);
}

}; // namespace zmdp

/***************************************************************************
 * REVISION HISTORY:
 * $Log: not supported by cvs2svn $
 * Revision 1.1  2006/04/12 19:22:41  trey
 * initial check-in
 *
 *
 ***************************************************************************/
<|endoftext|>


<commit_before>// Copyright (c) 2015
// Author: Chrono Law
#ifndef _NGX_GLOBAL_HPP
#define _NGX_GLOBAL_HPP

#include <boost/noncopyable.hpp>
#include "Nginx.hpp"

#define DECL_VAR(x, y)  decltype(y)& x = y

// apis: os(), err(), events(), process(), signal()
class NgxGlobal final
{
public:
    NgxGlobal() = default;
   ~NgxGlobal() = default;
public:
    struct os_info_t final : boost::noncopyable
    {
        DECL_VAR(pagesize, ngx_pagesize);
        DECL_VAR(cacheline_size, ngx_cacheline_size);
        DECL_VAR(pagesize_shift, ngx_pagesize_shift);

        DECL_VAR(ncpu, ngx_ncpu);
        DECL_VAR(max_sockets, ngx_max_sockets);
        DECL_VAR(inherited_nonblocking, ngx_inherited_nonblocking);
        DECL_VAR(tcp_nodelay_and_tcp_nopush, ngx_tcp_nodelay_and_tcp_nopush);

        // ngx_recv/ngx_send
        DECL_VAR(io, ngx_os_io);
    };

    static os_info_t& os()
    {
        static os_info_t o;
        return o;
    }
public:
    struct errno_info_t final : boost::noncopyable
    {
        DECL_VAR(no, ngx_errno);
        DECL_VAR(socket, ngx_socket_errno);
    };

    static errno_info_t& err()
    {
        static errno_info_t e;
        return e;
    }
public:
    struct process_info_t final : boost::noncopyable
    {
        // process/worker id
        DECL_VAR(id, ngx_pid);

        // process flag = NGX_PROCESS_MASTER/NGX_PROCESS_SINGLE/...
        DECL_VAR(type, ngx_process);

        DECL_VAR(new_binary, ngx_new_binary);

        DECL_VAR(daemonized, ngx_daemonized);
        DECL_VAR(exiting, ngx_exiting);

        DECL_VAR(channel, ngx_channel);
        DECL_VAR(slot, ngx_process_slot);
        DECL_VAR(last, ngx_last_process);

        // array for all processes
        DECL_VAR(array, ngx_processes);
    };

    static process_info_t& process()
    {
        static process_info_t p;
        return p;
    }
public:
    struct events_info_t final : boost::noncopyable
    {
        // ngx_add_event/ngx_del_event/...
        DECL_VAR(actions, ngx_event_actions);
        DECL_VAR(io, ngx_io);

        // sigalarm flag
        DECL_VAR(timer_alarm, ngx_event_timer_alarm);

        // epoll/kqueue flags, NGX_CLEAR_EVENT(EPOLLET)
        DECL_VAR(flags, ngx_event_flags);

        // flags
        DECL_VAR(use_accept_mutex, ngx_use_accept_mutex);
        DECL_VAR(accept_events, ngx_accept_events);
        DECL_VAR(accept_mutex_held, ngx_accept_mutex_held);
        DECL_VAR(accept_disabled, ngx_accept_disabled);

        // delay time in ms
        DECL_VAR(accept_mutex_delay, ngx_accept_mutex_delay);

        // queue
        DECL_VAR(posted_accept, ngx_posted_accept_events);
        DECL_VAR(posted, ngx_posted_events);
    };

    static events_info_t& events()
    {
        static events_info_t e;
        return e;
    }
public:
    struct signal_info_t final : boost::noncopyable
    {
        DECL_VAR(alrm, ngx_sigalrm);
        DECL_VAR(quit, ngx_quit);
        DECL_VAR(terminate, ngx_terminate);
        DECL_VAR(exiting, ngx_exiting);
        DECL_VAR(reap, ngx_reap);       //sigchld, reopen child
        DECL_VAR(reconfigure, ngx_reconfigure);
    };

    static signal_info_t& signal()
    {
        static signal_info_t s;
        return s;
    }
};

#undef DECL_VAR

#endif  //_NGX_GLOBAL_HPP
<commit_msg>small clean<commit_after>// Copyright (c) 2015
// Author: Chrono Law
#ifndef _NGX_GLOBAL_HPP
#define _NGX_GLOBAL_HPP

#include <boost/noncopyable.hpp>
#include "Nginx.hpp"

#define DECL_VAR(x, y)  decltype(y)& x = y

// apis: os(), err(), events(), process(), signal()
class NgxGlobal final
{
public:
    NgxGlobal() = default;
   ~NgxGlobal() = default;
public:
    struct os_info_t final : boost::noncopyable
    {
        DECL_VAR(pagesize, ngx_pagesize);
        DECL_VAR(cacheline_size, ngx_cacheline_size);
        DECL_VAR(pagesize_shift, ngx_pagesize_shift);

        DECL_VAR(ncpu, ngx_ncpu);
        DECL_VAR(max_sockets, ngx_max_sockets);
        DECL_VAR(inherited_nonblocking, ngx_inherited_nonblocking);
        DECL_VAR(tcp_nodelay_and_tcp_nopush, ngx_tcp_nodelay_and_tcp_nopush);

        // ngx_recv/ngx_send
        DECL_VAR(io, ngx_os_io);
    };

    static os_info_t& os()
    {
        static os_info_t o;
        return o;
    }
public:
    struct errno_info_t final : boost::noncopyable
    {
        DECL_VAR(no, ngx_errno);
        DECL_VAR(socket, ngx_socket_errno);
    };

    static errno_info_t& err()
    {
        static errno_info_t e;
        return e;
    }
public:
    struct process_info_t final : boost::noncopyable
    {
        // process/worker id
        DECL_VAR(id, ngx_pid);

        // process flag = NGX_PROCESS_MASTER/NGX_PROCESS_SINGLE/...
        DECL_VAR(type, ngx_process);

        DECL_VAR(new_binary, ngx_new_binary);

        DECL_VAR(daemonized, ngx_daemonized);
        DECL_VAR(exiting, ngx_exiting);

        DECL_VAR(channel, ngx_channel);
        DECL_VAR(slot, ngx_process_slot);
        DECL_VAR(last, ngx_last_process);

        // array for all processes
        DECL_VAR(array, ngx_processes);
    };

    static process_info_t& process()
    {
        static process_info_t p;
        return p;
    }
public:
    struct event_info_t final : boost::noncopyable
    {
        // ngx_add_event/ngx_del_event/...
        DECL_VAR(actions, ngx_event_actions);
        DECL_VAR(io, ngx_io);

        // sigalarm flag
        DECL_VAR(timer_alarm, ngx_event_timer_alarm);

        // epoll/kqueue flags, NGX_CLEAR_EVENT(EPOLLET)
        DECL_VAR(flags, ngx_event_flags);

        // flags
        DECL_VAR(use_accept_mutex, ngx_use_accept_mutex);
        DECL_VAR(accept_events, ngx_accept_events);
        DECL_VAR(accept_mutex_held, ngx_accept_mutex_held);
        DECL_VAR(accept_disabled, ngx_accept_disabled);

        // delay time in ms
        DECL_VAR(accept_mutex_delay, ngx_accept_mutex_delay);

        // queue
        DECL_VAR(posted_accept, ngx_posted_accept_events);
        DECL_VAR(posted, ngx_posted_events);
    };

    static event_info_t& event()
    {
        static event_info_t e;
        return e;
    }
public:
    struct signal_info_t final : boost::noncopyable
    {
        DECL_VAR(alrm, ngx_sigalrm);
        DECL_VAR(quit, ngx_quit);
        DECL_VAR(terminate, ngx_terminate);
        DECL_VAR(exiting, ngx_exiting);
        DECL_VAR(reap, ngx_reap);       //sigchld, reopen child
        DECL_VAR(reconfigure, ngx_reconfigure);
    };

    static signal_info_t& signal()
    {
        static signal_info_t s;
        return s;
    }
};

#undef DECL_VAR

#endif  //_NGX_GLOBAL_HPP
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: ary_disp.cxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: np $ $Date: 2002-03-08 14:45:19 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#include <precomp.h>
#include <ary/ary_disp.hxx>

// NOT FULLY DECLARED SERVICES
#include <ary/re.hxx>
#include <ary/r_disply.hxx>

namespace ary
{

void
Display::DisplaySlot_Rid( ary::Rid i_nId )
{
    const DisplayGate * pGate = Get_ReFinder();
    if (pGate != 0)
    {
         const RepositoryEntity * pRE = pGate->Find_Re( i_nId );
        if (pRE != 0)
        {
             pRE->StoreAt( *this );
            return;
        }
    }

    do_DisplaySlot_Rid( i_nId );
}

void
Display::DisplaySlot_LocalCe( ary::Rid          i_nId,
                              const udmstri &   i_sName )
{
    const DisplayGate * pGate = Get_ReFinder();
    if (pGate != 0)
    {
         const RepositoryEntity * pRE = pGate->Find_Re( i_nId );
        if (pRE != 0)
        {
             pRE->StoreAt( *this );
            return;
        }
    }

    do_DisplaySlot_LocalCe( i_nId, i_sName );
}

// Dummy implementations for class Display

void
Display::do_StartSlot()
{
}

void
Display::do_FinishSlot()
{
}

void
Display::do_DisplaySlot_Rid( ary::Rid )
{
}

void
Display::do_DisplaySlot_Lid( ary::Lid i_nId )
{
}

void
Display::do_DisplaySlot_LocalCe( ary::Rid           i_nId,
                                 const udmstri &    i_sName )
{
}

const DisplayGate *
Display::inq_Get_ReFinder() const
{
    return 0;
}

}   // namespace ary

<commit_msg>INTEGRATION: CWS ooo19126 (1.1.1.1.146); FILE MERGED 2005/09/05 13:10:27 rt 1.1.1.1.146.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ary_disp.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-07 17:10:17 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#include <precomp.h>
#include <ary/ary_disp.hxx>

// NOT FULLY DECLARED SERVICES
#include <ary/re.hxx>
#include <ary/r_disply.hxx>

namespace ary
{

void
Display::DisplaySlot_Rid( ary::Rid i_nId )
{
    const DisplayGate * pGate = Get_ReFinder();
    if (pGate != 0)
    {
         const RepositoryEntity * pRE = pGate->Find_Re( i_nId );
        if (pRE != 0)
        {
             pRE->StoreAt( *this );
            return;
        }
    }

    do_DisplaySlot_Rid( i_nId );
}

void
Display::DisplaySlot_LocalCe( ary::Rid          i_nId,
                              const udmstri &   i_sName )
{
    const DisplayGate * pGate = Get_ReFinder();
    if (pGate != 0)
    {
         const RepositoryEntity * pRE = pGate->Find_Re( i_nId );
        if (pRE != 0)
        {
             pRE->StoreAt( *this );
            return;
        }
    }

    do_DisplaySlot_LocalCe( i_nId, i_sName );
}

// Dummy implementations for class Display

void
Display::do_StartSlot()
{
}

void
Display::do_FinishSlot()
{
}

void
Display::do_DisplaySlot_Rid( ary::Rid )
{
}

void
Display::do_DisplaySlot_Lid( ary::Lid i_nId )
{
}

void
Display::do_DisplaySlot_LocalCe( ary::Rid           i_nId,
                                 const udmstri &    i_sName )
{
}

const DisplayGate *
Display::inq_Get_ReFinder() const
{
    return 0;
}

}   // namespace ary

<|endoftext|>


<commit_before>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: cfrstd.cxx,v $
 * $Revision: 1.15 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#include <precomp.h>
#include <cfrstd.hxx>

// NOT FULLY DEFINED SERVICES
#include <ctime>

/*                      CSS Styles
                        ----------

Colors:
-   light background color              #eeeeff
-   dark background color               #ccccff
-   self in navibar background color    #2222ad

Fonts:
-   page title              20, bold, Arial
-   navibar main            12, bold, Arial
-   navibar sub              8, Arial, kapitlchen
-   attrtable title line     8, bold, Arial, kapitlchen
-   attrtable value line     8, Arial kapitlchen

-   namespace chain         13, bold
-   table title             13, bold
-   template line           13

-   member paragraph title  12, bold

-   docu paragraph title    11, bold
-   standard text           11

-   hierarchy               11, monospace

classes:

    td.title                page title
    h3                      table title
    h4                      member paragraph title

    td.nmain                navigation main bar
    td.nsub                 navigation sub bar
    a.nmain                 links in navigation main bar
    a.nsub                  links in navigation sub bar

    td.attr1                attribute table head line
    td.attr2                attribute table value line

    p.namechain             namespace chain in head of pages
    p.tpl                   template line in head of pages

    pre.doc                 preformatted docu
    pre.hierarchy           class bases hierarchy graphic

    dl.syntax               function- or variable-declaration field
    a.syntax                link in function- or variable-declaration field

    p.dt                    docu paragraph title
    dl.dt                   docu paragraph title

    p                       standard text
    dl                      standard text
    dd                      standard text
*/

#define CRLF "\n"

namespace
{

bool            bUse_OOoFrameDiv = true;

//***************   These are used for IDL currently only!   ********************

const char * const C_sStdStyle =
    "/*See bottom of file for explanations.*/"CRLF
    CRLF
    "body { background-color:#ffffff; }"CRLF
    CRLF
    "h3             { font-size:13pt; font-weight:bold;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "p, dt, dd, pre { font-size:11pt;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "pre            { font-family:monospace; }"CRLF
    CRLF
    "table.navimain { background-color:#eeeeff; }"CRLF
    "table.subtitle { margin-top:6pt; margin-bottom:6pt; }"CRLF
    CRLF
    "td             {                     font-size:11pt; }"CRLF
    "td.title       { font-family: Arial; font-size:19pt; font-weight:bold;"CRLF
    "                 line-height:30pt;   background-color:#ccccff; text-align:center; }"CRLF
    "td.subtitle    { font-family: Arial; font-size:13pt;"CRLF
    "                 line-height:20pt;   background-color:#ccccff; }"CRLF
    "td.crosstitle  {                     font-size:12pt; font-weight:bold;"CRLF
    "                 line-height:15pt;   background-color:#eeeeff; }"CRLF
    "td.imdetail    { width:100%;         background-color:#eeeeff; }"CRLF
    CRLF
    "td.imsum_left  { width:30%;  }"CRLF
    "td.imsum_right { width:70%;  }"CRLF
    CRLF
    "td.navimain, a.navimain"CRLF
    "                   { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold; }"CRLF
    "td.navimainself    { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold;"CRLF
    "                     color:#ffffff; background-color:#2222ad; }"CRLF
    "td.navimainnone    { text-align:center; font-family: Arial; font-size:12pt; }"CRLF
    "td.navisub, a.navisub"CRLF
    "                   { text-align:center; font-family: Arial; font-size:9pt; font-variant:small-caps; }"CRLF
    "td.navimain, td.navisub"CRLF
    "                   { padding-left:7pt; padding-right:7pt; }"CRLF
    CRLF
    "a.membertitle  { font-size:12pt; font-weight:bold; line-height:18pt; }"CRLF
    "a.navimain, a.navisub  { color:#000000; }"CRLF
    ".dt            { font-weight:bold; }"CRLF
    ".namechain     { font-size:13pt; font-weight:bold;"CRLF
    "                 margin-top:3pt; margin-bottom:6pt; }"CRLF
    ".title2        { font-size:13pt; font-style:italic; font-weight:bold; text-align:left; }"CRLF
    ;

const char * const C_sCssExplanations =
    "/* Explanation of CSS classes:"CRLF
    CRLF
    ".navimain          Text in main navigation bar."CRLF
    ".navisub           Text in lower navigation bar."CRLF
    "td.navimainself    Cell in main navigation bar with \"selected\" shadow: You are here."CRLF
    "td.navimainnone    Cell in main navigation bar with no link."CRLF
    CRLF
    ".namechain         Line with current module path."CRLF
    CRLF
    "td.crosstitle      Comment box for bases (base interfaces etc.)"CRLF
    "td.imsum_left      Left part of such boxes."CRLF
    "td.imsum_right     Right part of such boxes."CRLF
    CRLF
    "td.title           Main title of the page like \"interface XYz\""CRLF
    ".subtitle          Tables, and head cells of those, which list members"CRLF
    "                   like \"method summary\" and \"method details\"."CRLF
    CRLF
    "td.imdetail        Background table of method's detail description."CRLF
    "a.membertitle      Method name (as jump label) in method's detail"CRLF
    "                   description."CRLF
    ".title2            smaller font prefixes to page titles"CRLF
    "*/"CRLF
    ;

const char * const C_sStdStyle_withDivFrame =
    "/*See bottom of file for explanations.*/"CRLF
    CRLF
    "body { background-color:#ffffff; }"CRLF
    CRLF
    "#adc-idlref h3 { font-size:13pt; font-weight:bold;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "#adc-idlref p, #adc-idlref dt, #adc-idlref dd, #adc-idlref pre"CRLF
    "               { font-size:11pt;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "#adc-idlref pre    { font-family:monospace; }"CRLF
    CRLF
    "#adc-idlref table.navimain { background-color:#eeeeff; }"CRLF
    "#adc-idlref table.subtitle { margin-top:6pt; margin-bottom:6pt; }"CRLF
    CRLF
    "#adc-idlref td             { font-size:11pt; }"CRLF
    "#adc-idlref td.title       { font-family: Arial; font-size:19pt; font-weight:bold;"CRLF
    "                             line-height:30pt;   background-color:#ccccff; text-align:center; }"CRLF
    "#adc-idlref td.subtitle    { font-family: Arial; font-size:13pt;"CRLF
    "                             line-height:20pt;   background-color:#ccccff; }"CRLF
    "#adc-idlref td.crosstitle  { font-size:12pt; font-weight:bold;"CRLF
    "                             line-height:15pt;   background-color:#eeeeff; }"CRLF
    "#adc-idlref td.imdetail    { width:100%;         background-color:#eeeeff; }"CRLF
    CRLF
    "#adc-idlref td.imsum_left  { width:30%;  }"CRLF
    "#adc-idlref td.imsum_right { width:70%;  }"CRLF
    CRLF
    "#adc-idlref td.navimain, #adc-idlref a.navimain"CRLF
    "                   { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold; }"CRLF
    "#adc-idlref td.navimainself    { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold;"CRLF
    "                                 color:#ffffff; background-color:#2222ad; }"CRLF
    "#adc-idlref td.navimainnone    { text-align:center; font-family: Arial; font-size:12pt; }"CRLF
    "#adc-idlref td.navisub, #adc-idlref a.navisub"CRLF
    "                   { text-align:center; font-family: Arial; font-size:9pt; font-variant:small-caps; }"CRLF
    "#adc-idlref td.navimain, #adc-idlref td.navisub"CRLF
    "                   { padding-left:7pt; padding-right:7pt; }"CRLF
    CRLF
    "#adc-idlref a.membertitle  { font-size:12pt; font-weight:bold; line-height:18pt; }"CRLF
    "#adc-idlref a.navimain, #adc-idlref a.navisub  { color:#000000; }"CRLF
    "#adc-idlref .dt            { font-weight:bold; }"CRLF
    "#adc-idlref .namechain     { font-size:13pt; font-weight:bold;"CRLF
    "                             margin-top:3pt; margin-bottom:6pt; }"CRLF
    "#adc-idlref .title2        { font-size:13pt; font-style:italic; font-weight:bold; text-align:left; }"CRLF
    ""CRLF
    "#adc-idlref table { empty-cells:show; }"CRLF
    ""CRLF
    "#adc-idlref .childlist td, "CRLF
    "#adc-idlref .commentedlinks td, "CRLF
    "#adc-idlref .memberlist td, "CRLF
    "#adc-idlref .subtitle td, "CRLF
    "#adc-idlref .crosstitle td  { border: .1pt solid #000000; }"CRLF
    ""CRLF
    "#adc-idlref .flag-table td { border: .1pt solid #cccccc; } "CRLF
    ""CRLF
    "#adc-idlref .title-table td, "CRLF
    "#adc-idlref .table-in-method td, "CRLF
    "#adc-idlref .table-in-data td, "CRLF
    "#adc-idlref .navimain td, "CRLF
    "#adc-idlref .navisub td, "CRLF
    "#adc-idlref .expl-table td, "CRLF
    "#adc-idlref .param-table td  { border: none; }"CRLF
    ;

}   // anonymous namespace

StdFrame::StdFrame()
    :   sDevelopersGuideHtmlRoot(),
        bSimpleLinks(false)
{
}

DYN Html_Image *
StdFrame::LogoSrc() const
{
    return 0;

//    return  new Html_Image( "logodot-blu.gif",
//                            "109",
//                            "54",
//                            "RIGHT",
//                            "0",
//                            "OpenOffice" );

}

const char *
StdFrame::LogoLink() const
{
    return "";
//  return "http://www.sun.com";
//  return "http://www.openoffice.org";
}

String              MakeCopyRight();

const char *
StdFrame::CopyrightText() const
{
    static String sCopyRight_( MakeCopyRight() );
    return sCopyRight_.c_str();
}

const char *
StdFrame::CssStyle() const
{
    if (bUse_OOoFrameDiv)
        return C_sStdStyle_withDivFrame;
    else
        return C_sStdStyle;
}

const char *
StdFrame::CssStylesExplanation() const
{
    return C_sCssExplanations;
}

const char *
StdFrame::DevelopersGuideHtmlRoot() const
{
    return sDevelopersGuideHtmlRoot;
}

bool
StdFrame::SimpleLinks() const
{
    return bSimpleLinks;
}

void
StdFrame::Set_DevelopersGuideHtmlRoot( const String & i_directory )
{
    if (NOT i_directory.empty())
    {
        if (i_directory.char_at(i_directory.length()-1) == '/')
        {
            sDevelopersGuideHtmlRoot.assign(i_directory,i_directory.length()-1);
            return;
        }
    }
    sDevelopersGuideHtmlRoot = i_directory;
}

void
StdFrame::Set_SimpleLinks()
{
    bSimpleLinks = true;
}

String
MakeCopyRight()
{
    StreamStr cr(700);
    std::time_t
        gt;
    std::time(&gt);
    std::tm *
        plt = std::localtime(&gt);
    int year = 1900 + plt->tm_year;

    cr  << "Copyright © "
        << year
        << " Sun Microsystems, Inc.";
    return String(cr.c_str());

//  return "Copyright © 2003 Sun Microsystems, Inc.";
//  return "Copyright © 2002 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA.";
//  return "Copyright 2001 OpenOffice.org Foundation. All Rights Reserved.";
}
<commit_msg>#i90829# Remove 'std::' for time and localtime.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: cfrstd.cxx,v $
 * $Revision: 1.16 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#include <precomp.h>
#include <cfrstd.hxx>

// NOT FULLY DEFINED SERVICES
#include <ctime>

/*                      CSS Styles
                        ----------

Colors:
-   light background color              #eeeeff
-   dark background color               #ccccff
-   self in navibar background color    #2222ad

Fonts:
-   page title              20, bold, Arial
-   navibar main            12, bold, Arial
-   navibar sub              8, Arial, kapitlchen
-   attrtable title line     8, bold, Arial, kapitlchen
-   attrtable value line     8, Arial kapitlchen

-   namespace chain         13, bold
-   table title             13, bold
-   template line           13

-   member paragraph title  12, bold

-   docu paragraph title    11, bold
-   standard text           11

-   hierarchy               11, monospace

classes:

    td.title                page title
    h3                      table title
    h4                      member paragraph title

    td.nmain                navigation main bar
    td.nsub                 navigation sub bar
    a.nmain                 links in navigation main bar
    a.nsub                  links in navigation sub bar

    td.attr1                attribute table head line
    td.attr2                attribute table value line

    p.namechain             namespace chain in head of pages
    p.tpl                   template line in head of pages

    pre.doc                 preformatted docu
    pre.hierarchy           class bases hierarchy graphic

    dl.syntax               function- or variable-declaration field
    a.syntax                link in function- or variable-declaration field

    p.dt                    docu paragraph title
    dl.dt                   docu paragraph title

    p                       standard text
    dl                      standard text
    dd                      standard text
*/

#define CRLF "\n"

namespace
{

bool            bUse_OOoFrameDiv = true;

//***************   These are used for IDL currently only!   ********************

const char * const C_sStdStyle =
    "/*See bottom of file for explanations.*/"CRLF
    CRLF
    "body { background-color:#ffffff; }"CRLF
    CRLF
    "h3             { font-size:13pt; font-weight:bold;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "p, dt, dd, pre { font-size:11pt;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "pre            { font-family:monospace; }"CRLF
    CRLF
    "table.navimain { background-color:#eeeeff; }"CRLF
    "table.subtitle { margin-top:6pt; margin-bottom:6pt; }"CRLF
    CRLF
    "td             {                     font-size:11pt; }"CRLF
    "td.title       { font-family: Arial; font-size:19pt; font-weight:bold;"CRLF
    "                 line-height:30pt;   background-color:#ccccff; text-align:center; }"CRLF
    "td.subtitle    { font-family: Arial; font-size:13pt;"CRLF
    "                 line-height:20pt;   background-color:#ccccff; }"CRLF
    "td.crosstitle  {                     font-size:12pt; font-weight:bold;"CRLF
    "                 line-height:15pt;   background-color:#eeeeff; }"CRLF
    "td.imdetail    { width:100%;         background-color:#eeeeff; }"CRLF
    CRLF
    "td.imsum_left  { width:30%;  }"CRLF
    "td.imsum_right { width:70%;  }"CRLF
    CRLF
    "td.navimain, a.navimain"CRLF
    "                   { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold; }"CRLF
    "td.navimainself    { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold;"CRLF
    "                     color:#ffffff; background-color:#2222ad; }"CRLF
    "td.navimainnone    { text-align:center; font-family: Arial; font-size:12pt; }"CRLF
    "td.navisub, a.navisub"CRLF
    "                   { text-align:center; font-family: Arial; font-size:9pt; font-variant:small-caps; }"CRLF
    "td.navimain, td.navisub"CRLF
    "                   { padding-left:7pt; padding-right:7pt; }"CRLF
    CRLF
    "a.membertitle  { font-size:12pt; font-weight:bold; line-height:18pt; }"CRLF
    "a.navimain, a.navisub  { color:#000000; }"CRLF
    ".dt            { font-weight:bold; }"CRLF
    ".namechain     { font-size:13pt; font-weight:bold;"CRLF
    "                 margin-top:3pt; margin-bottom:6pt; }"CRLF
    ".title2        { font-size:13pt; font-style:italic; font-weight:bold; text-align:left; }"CRLF
    ;

const char * const C_sCssExplanations =
    "/* Explanation of CSS classes:"CRLF
    CRLF
    ".navimain          Text in main navigation bar."CRLF
    ".navisub           Text in lower navigation bar."CRLF
    "td.navimainself    Cell in main navigation bar with \"selected\" shadow: You are here."CRLF
    "td.navimainnone    Cell in main navigation bar with no link."CRLF
    CRLF
    ".namechain         Line with current module path."CRLF
    CRLF
    "td.crosstitle      Comment box for bases (base interfaces etc.)"CRLF
    "td.imsum_left      Left part of such boxes."CRLF
    "td.imsum_right     Right part of such boxes."CRLF
    CRLF
    "td.title           Main title of the page like \"interface XYz\""CRLF
    ".subtitle          Tables, and head cells of those, which list members"CRLF
    "                   like \"method summary\" and \"method details\"."CRLF
    CRLF
    "td.imdetail        Background table of method's detail description."CRLF
    "a.membertitle      Method name (as jump label) in method's detail"CRLF
    "                   description."CRLF
    ".title2            smaller font prefixes to page titles"CRLF
    "*/"CRLF
    ;

const char * const C_sStdStyle_withDivFrame =
    "/*See bottom of file for explanations.*/"CRLF
    CRLF
    "body { background-color:#ffffff; }"CRLF
    CRLF
    "#adc-idlref h3 { font-size:13pt; font-weight:bold;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "#adc-idlref p, #adc-idlref dt, #adc-idlref dd, #adc-idlref pre"CRLF
    "               { font-size:11pt;"CRLF
    "                 margin-top:3pt; margin-bottom:1pt; }"CRLF
    "#adc-idlref pre    { font-family:monospace; }"CRLF
    CRLF
    "#adc-idlref table.navimain { background-color:#eeeeff; }"CRLF
    "#adc-idlref table.subtitle { margin-top:6pt; margin-bottom:6pt; }"CRLF
    CRLF
    "#adc-idlref td             { font-size:11pt; }"CRLF
    "#adc-idlref td.title       { font-family: Arial; font-size:19pt; font-weight:bold;"CRLF
    "                             line-height:30pt;   background-color:#ccccff; text-align:center; }"CRLF
    "#adc-idlref td.subtitle    { font-family: Arial; font-size:13pt;"CRLF
    "                             line-height:20pt;   background-color:#ccccff; }"CRLF
    "#adc-idlref td.crosstitle  { font-size:12pt; font-weight:bold;"CRLF
    "                             line-height:15pt;   background-color:#eeeeff; }"CRLF
    "#adc-idlref td.imdetail    { width:100%;         background-color:#eeeeff; }"CRLF
    CRLF
    "#adc-idlref td.imsum_left  { width:30%;  }"CRLF
    "#adc-idlref td.imsum_right { width:70%;  }"CRLF
    CRLF
    "#adc-idlref td.navimain, #adc-idlref a.navimain"CRLF
    "                   { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold; }"CRLF
    "#adc-idlref td.navimainself    { text-align:center; font-family: Arial; font-size:12pt; font-weight:bold;"CRLF
    "                                 color:#ffffff; background-color:#2222ad; }"CRLF
    "#adc-idlref td.navimainnone    { text-align:center; font-family: Arial; font-size:12pt; }"CRLF
    "#adc-idlref td.navisub, #adc-idlref a.navisub"CRLF
    "                   { text-align:center; font-family: Arial; font-size:9pt; font-variant:small-caps; }"CRLF
    "#adc-idlref td.navimain, #adc-idlref td.navisub"CRLF
    "                   { padding-left:7pt; padding-right:7pt; }"CRLF
    CRLF
    "#adc-idlref a.membertitle  { font-size:12pt; font-weight:bold; line-height:18pt; }"CRLF
    "#adc-idlref a.navimain, #adc-idlref a.navisub  { color:#000000; }"CRLF
    "#adc-idlref .dt            { font-weight:bold; }"CRLF
    "#adc-idlref .namechain     { font-size:13pt; font-weight:bold;"CRLF
    "                             margin-top:3pt; margin-bottom:6pt; }"CRLF
    "#adc-idlref .title2        { font-size:13pt; font-style:italic; font-weight:bold; text-align:left; }"CRLF
    ""CRLF
    "#adc-idlref table { empty-cells:show; }"CRLF
    ""CRLF
    "#adc-idlref .childlist td, "CRLF
    "#adc-idlref .commentedlinks td, "CRLF
    "#adc-idlref .memberlist td, "CRLF
    "#adc-idlref .subtitle td, "CRLF
    "#adc-idlref .crosstitle td  { border: .1pt solid #000000; }"CRLF
    ""CRLF
    "#adc-idlref .flag-table td { border: .1pt solid #cccccc; } "CRLF
    ""CRLF
    "#adc-idlref .title-table td, "CRLF
    "#adc-idlref .table-in-method td, "CRLF
    "#adc-idlref .table-in-data td, "CRLF
    "#adc-idlref .navimain td, "CRLF
    "#adc-idlref .navisub td, "CRLF
    "#adc-idlref .expl-table td, "CRLF
    "#adc-idlref .param-table td  { border: none; }"CRLF
    ;

}   // anonymous namespace

StdFrame::StdFrame()
    :   sDevelopersGuideHtmlRoot(),
        bSimpleLinks(false)
{
}

DYN Html_Image *
StdFrame::LogoSrc() const
{
    return 0;

//    return  new Html_Image( "logodot-blu.gif",
//                            "109",
//                            "54",
//                            "RIGHT",
//                            "0",
//                            "OpenOffice" );

}

const char *
StdFrame::LogoLink() const
{
    return "";
//  return "http://www.sun.com";
//  return "http://www.openoffice.org";
}

String              MakeCopyRight();

const char *
StdFrame::CopyrightText() const
{
    static String sCopyRight_( MakeCopyRight() );
    return sCopyRight_.c_str();
}

const char *
StdFrame::CssStyle() const
{
    if (bUse_OOoFrameDiv)
        return C_sStdStyle_withDivFrame;
    else
        return C_sStdStyle;
}

const char *
StdFrame::CssStylesExplanation() const
{
    return C_sCssExplanations;
}

const char *
StdFrame::DevelopersGuideHtmlRoot() const
{
    return sDevelopersGuideHtmlRoot;
}

bool
StdFrame::SimpleLinks() const
{
    return bSimpleLinks;
}

void
StdFrame::Set_DevelopersGuideHtmlRoot( const String & i_directory )
{
    if (NOT i_directory.empty())
    {
        if (i_directory.char_at(i_directory.length()-1) == '/')
        {
            sDevelopersGuideHtmlRoot.assign(i_directory,i_directory.length()-1);
            return;
        }
    }
    sDevelopersGuideHtmlRoot = i_directory;
}

void
StdFrame::Set_SimpleLinks()
{
    bSimpleLinks = true;
}

String
MakeCopyRight()
{
    StreamStr cr(700);
    std::time_t
        gt;
    time(&gt);
    std::tm *
        plt = localtime(&gt);
    int year = 1900 + plt->tm_year;

    cr  << "Copyright © "
        << year
        << " Sun Microsystems, Inc.";
    return String(cr.c_str());

//  return "Copyright © 2003 Sun Microsystems, Inc.";
//  return "Copyright © 2002 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA.";
//  return "Copyright 2001 OpenOffice.org Foundation. All Rights Reserved.";
}
<|endoftext|>