Skip to content
Snippets Groups Projects
Commit 1dbe4587 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Renaming Ellpack graph to Ellpack network.

parent 6222ba20
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,9 @@ ADD_SUBDIRECTORY( functors ) ...@@ -3,9 +3,9 @@ ADD_SUBDIRECTORY( functors )
ADD_SUBDIRECTORY( config ) ADD_SUBDIRECTORY( config )
ADD_SUBDIRECTORY( core ) ADD_SUBDIRECTORY( core )
ADD_SUBDIRECTORY( debug ) ADD_SUBDIRECTORY( debug )
ADD_SUBDIRECTORY( graphs )
ADD_SUBDIRECTORY( matrices ) ADD_SUBDIRECTORY( matrices )
ADD_SUBDIRECTORY( mesh ) ADD_SUBDIRECTORY( mesh )
ADD_SUBDIRECTORY( networks )
ADD_SUBDIRECTORY( operators ) ADD_SUBDIRECTORY( operators )
ADD_SUBDIRECTORY( problems ) ADD_SUBDIRECTORY( problems )
ADD_SUBDIRECTORY( solvers ) ADD_SUBDIRECTORY( solvers )
......
...@@ -3,18 +3,18 @@ SET( headers tnlEllpackGraph.h ...@@ -3,18 +3,18 @@ SET( headers tnlEllpackGraph.h
tnlEllpackGraphLinksAccessor.h tnlEllpackGraphLinksAccessor.h
tnlEllpackGraphLinksAccessor_impl.h ) tnlEllpackGraphLinksAccessor_impl.h )
SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/graphs ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/networks )
set( common_SOURCES set( common_SOURCES
) )
IF( BUILD_CUDA ) IF( BUILD_CUDA )
set( tnl_graphs_CUDA__SOURCES set( tnl_networks_CUDA__SOURCES
${common_SOURCES} ${common_SOURCES}
PARENT_SCOPE ) PARENT_SCOPE )
ENDIF() ENDIF()
set( tnl_graphs_SOURCES set( tnl_networks_SOURCES
${common_SOURCES} ${common_SOURCES}
PARENT_SCOPE ) PARENT_SCOPE )
INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/graphs ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/networks )
\ No newline at end of file \ No newline at end of file
/*************************************************************************** /***************************************************************************
tnlEllpackGraph.h - description tnlEllpackNetwork.h - description
------------------- -------------------
begin : Sep 9, 2015 begin : Sep 9, 2015
copyright : (C) 2015 by Tomas Oberhuber et al. copyright : (C) 2015 by Tomas Oberhuber et al.
...@@ -15,44 +15,50 @@ ...@@ -15,44 +15,50 @@
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef TNLELLPACKGRAPH_H #ifndef TNLELLPACKNETWORK_H
#define TNLELLPACKGRAPH_H #define TNLELLPACKNETWORK_H
#include <graphs/sparse/tnlEllpackGraphLinksAccessor.h> #include <networks/tnlEllpackNetworkPorts.h>
template< typename Device = tnlHost, template< typename Device = tnlHost,
typename Index = int > typename Index = int >
class tnlEllpackGraphConstLinksAccessor; class tnlEllpackNetworkConstPorts;
template< typename Device = tnlHost, template< typename Device = tnlHost,
typename Index = int > typename Index = int >
class tnlEllpackGraph class tnlEllpackNetwork
{ {
public: public:
typedef Device DeviceType; typedef Device DeviceType;
typedef Index IndexType; typedef Index IndexType;
typedef tnlEllpackGraphLinksAccessor< DeviceType, IndexType > LinksAccessorType; typedef tnlEllpackNetworkPorts< DeviceType, IndexType > PortsType;
typedef tnlEllpackGraphConstLinksAccessor< DeviceType, IndexType > ConstLinksAccessorType; typedef tnlEllpackNetworkConstPorts< DeviceType, IndexType > ConstPortsType;
typedef tnlVector< IndexType, DeviceType, IndexType > LinksPerNodesVectorType; typedef tnlVector< IndexType, DeviceType, IndexType > PortsAllocationVectorType;
tnlEllpackGraph(); tnlEllpackNetwork();
void setNumberOfNodes( const IndexType nodes ); void setDimensions( const IndexType inputs,
const IndexType outputs );
void setNumberOfLinksPerNode( const LinksPerNodesVectorType& linksPerNode ); const IndexType getInputsCount() const;
LinksAccessorType getNodeLinksAccessor( const IndexType& nodeIndex ); const IndexType getOutputsCount() const;
ConstLinksAccessorType getNodeLinksAccessor( const IndexType& nodeIndex ) const; void allocatePorts( const PortsAllocationVectorType& portsCount );
PortsType getPorts( const IndexType& inputIndex );
ConstPortsType getPorts( const IndexType& inputIndex ) const;
protected: protected:
tnlVector< IndexType, DeviceType, IndexType > links; tnlVector< IndexType, DeviceType, IndexType > links;
IndexType maxLinksPerNode, numberOfNodes; IndexType inputs, outputs, portsMaxCount;
}; };
#include <networks/tnlEllpackNetworks_impl.h>
#endif /* TNLELLPACKGRAPH_H */ #endif /* TNLELLPACKNETWORK_H */
/*************************************************************************** /***************************************************************************
tnlEllpackGraph.h - description tnlEllpackNetworkPorts.h - description
------------------- -------------------
begin : Sep 10, 2015 begin : Sep 10, 2015
copyright : (C) 2015 by Tomas Oberhuber et al. copyright : (C) 2015 by Tomas Oberhuber et al.
...@@ -15,43 +15,43 @@ ...@@ -15,43 +15,43 @@
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef TNLELLPACKGRAPHLINKSACCESSOR_H #ifndef TNLELLPACKNETWORKPORTS_H
#define TNLELLPACKGRAPHLINKSACCESSOR_H #define TNLELLPACKNETWORKPORTS_H
template< typename Device, template< typename Device,
typename Index > typename Index >
class tnlEllpackGraphLinksAccessor class tnlEllpackNetworkPorts
{ {
public: public:
typedef Device DeviceType; typedef Device DeviceType;
typedef Index IndexType; typedef Index IndexType;
typedef tnlEllpackGraph< DeviceType, IndexType > GraphType; typedef tnlEllpackNetwork< DeviceType, IndexType > NetworkType;
void setLink( const IndexType linkIndex, void setOutput( const IndexType portIndex,
const IndexType targetNode ); const IndexType output );
IndexType getLinkTarget( const IndexType linkIndex ) const; IndexType getOutput( const IndexType portIndex ) const;
IndexType& operator[]( const IndexType linkIndex ); IndexType& operator[]( const IndexType portIndex );
const IndexType& operator[]( const IndexType linkIndex ) const; const IndexType& operator[]( const IndexType portIndex ) const;
protected: protected:
tnlEllpackGraphLinksAccessor( IndexType* graphLinks, tnlEllpackNetworkPorts( IndexType* ports,
const IndexType node, const IndexType input,
const maxLinksPerNode ); const IndexType portsMaxCount );
IndexType* links; IndexType* ports;
IndexType step, maxLinksPerNode; IndexType step;
friend tnlEllpackGraph< IndexType, DeviceType >; friend tnlEllpackNetwork< IndexType, DeviceType >;
}; };
#include <graphs/sparse/tnlEllpackGraphLinksAccessor_impl.h> #include <networks/tnlEllpackNetworkPorts_impl.h>
#endif /* TNLELLPACKGRAPHLINKSACCESSOR_H */ #endif /* TNLELLPACKNETWORKPORTS_H */
/*************************************************************************** /***************************************************************************
tnlEllpackGraph_impl.h - description tnlEllpackNetworkPorts_impl.h - description
------------------- -------------------
begin : Sep 10, 2015 begin : Sep 10, 2015
copyright : (C) 2015 by Tomas Oberhuber et al. copyright : (C) 2015 by Tomas Oberhuber et al.
...@@ -15,56 +15,56 @@ ...@@ -15,56 +15,56 @@
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef TNLELLPACKGRAPHLINKSACCESSOR_IMPL_H #ifndef TNLELLPACKNETWORKPORTS_IMPL_H
#define TNLELLPACKGRAPHLINKSACCESSOR_IMPL_H #define TNLELLPACKNETWORKPORTS_IMPL_H
template< typename Device, template< typename Device,
typename Index > typename Index >
tnlEllpackGraphLinksAccessor< Device, Index >:: tnlEllpackNetworkPorts< Device, Index >::
tnlEllpackGraphLinksAccessor( IndexType* graphLinks, tnlEllpackNetworkPorts( IndexType* networkPorts,
const IndexType node, const IndexType input,
const IndexType maxLinksPerNode ) const IndexType portsMaxCount )
{ {
this->links = &graphLinks[ node * maxLinksPerNode ]; this->ports = &networkPorts[ input * portsMaxCount ];
this->maxLinksPerNode = maxLinksPerNode; this->portsMaxCount = portsMaxCount;
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
void void
tnlEllpackGraphLinksAccessor< Device, Index >:: tnlEllpackNetworkPorts< Device, Index >::
setLink( const IndexType linkIndex, setOutput( const IndexType portIndex,
const IndexType targetNode ) const IndexType output )
{ {
links[ linkIndex ] = targetNode; this->ports[ portIndex ] = ouput;
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
Index Index
tnlEllpackGraphLinksAccessor< Device, Index >:: tnlEllpackNetworkPorts< Device, Index >::
getLinkTarget( const IndexType linkIndex ) const getOutput( const IndexType portIndex ) const
{ {
return links[ linkIndex ]; return this->ports[ portIndex ];
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
Index& Index&
tnlEllpackGraphLinksAccessor< Device, Index >:: tnlEllpackNetworkPorts< Device, Index >::
operator[]( const IndexType linkIndex ) operator[]( const IndexType portIndex )
{ {
return links[ linkIndex ]; return this->ports[ portIndex ];
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
const Index& const Index&
tnlEllpackGraphLinksAccessor< Device, Index >:: tnlEllpackNetworkPorts< Device, Index >::
operator[]( const IndexType linkIndex ) const operator[]( const IndexType portIndex ) const
{ {
return links[ linkIndex ]; return this->ports[ portIndex ];
} }
......
/*************************************************************************** /***************************************************************************
tnlEllpackGraph_impl.h - description tnlEllpackNetwork_impl.h - description
------------------- -------------------
begin : Sep 9, 2015 begin : Sep 9, 2015
copyright : (C) 2015 by Tomas Oberhuber et al. copyright : (C) 2015 by Tomas Oberhuber et al.
...@@ -15,60 +15,81 @@ ...@@ -15,60 +15,81 @@
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef TNLELLPACKGRAPH_IMPL_H #ifndef TNLELLPACKNETWORK_IMPL_H
#define TNLELLPACKGRAPH_IMPL_H #define TNLELLPACKNETWORK_IMPL_H
#include "tnlEllpackGraph.h" #include <networks/tnlEllpackNetwork.h>
template< typename Device, template< typename Device,
typename Index > typename Index >
tnlEllpackGraph< Device, Index >:: tnlEllpackNetwork< Device, Index >::
tnlEllpackGraph() tnlEllpackNetwork()
: maxLinksPerNode( 0 ), numberOfNodes( 0 ) : inputs( 0 ), outputs( 0 ), portsMaxCount( 0 )
{ {
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
void void
tnlEllpackGraph< Device, Index >:: tnlEllpackNetwork< Device, Index >::
setNumberOfNodes( const IndexType nodes ) setDimensions( const IndexType inputs,
const IndexType outputs )
{ {
this->numberOfNodes = nodes; this->inputs = inputs;
this->outputs = outputs;
}
template< typename Device,
typename Index >
const Index
tnlEllpackNetwork< Device, Index >::
getInputsCount() const
{
return this->inputs;
}
template< typename Device,
typename Index >
const Index
tnlEllpackNetwork< Device, Index >::
getOutputsCount() const
{
return this->outputs;
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
void void
tnlEllpackGraph< Device, Index >:: tnlEllpackNetwork< Device, Index >::
setNumberOfLinksPerNode( const LinksPerNodesVectorType& linksPerNode ) allocatePorts( const PortsAllocationVectorType& portsCount )
{ {
tnlAssert( linksPerNode.getSize() == this->numberOfNodes, tnlAssert( portsCount.getSize() == this->inputs,
cerr << "linksPerNode.getSize() = " << linksPerNode.getSize() cerr << "portsCount.getSize() = " << portsCount.getSize()
<< "this->numberOfNodes = " << this->numberOfNodes ); << "this->inputs = " << this->inputs );
this->maxLinksPerNode = linksPerNode.max(); this->portsMaxCount = portsCount.max();
tnlAssert( this->maxLinksPerNode >= 0, tnlAssert( this->portsMaxCount >= 0 && this->portsMaxCount <= this->outputs,
cerr << "this->maxLinksPerNode = " << this->maxLinksPerNode ); cerr << "this->portsMaxCount = " << this->portsMaxCount
<< " this->outputs = " << this->outputs );
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
typename tnlEllpackGraph< Device, Index >::LinksAccessorType typename tnlEllpackNetwork< Device, Index >::LinksAccessorType
tnlEllpackGraph< Device, Index >:: tnlEllpackNetwork< Device, Index >::
getNodeLinksAccessor( const IndexType& nodeIndex ) getPorts( const IndexType& inputIndex )
{ {
return LinksAccessorType( this->links.getData(), nodeIndex, this->maxLinksPerNode ); return PortsType( this->links.getData(), inputIndex, this->portsMaxCount );
} }
template< typename Device, template< typename Device,
typename Index > typename Index >
typename tnlEllpackGraph< Device, Index >::ConstLinksAccessorType typename tnlEllpackNetwork< Device, Index >::ConstLinksAccessorType
tnlEllpackGraph< Device, Index >:: tnlEllpackNetwork< Device, Index >::
getNodeLinksAccessor( const IndexType& nodeIndex ) const getPorts( const IndexType& inputIndex ) const
{ {
return ConstLinksAccessorType( this->links.getData(), nodeIndex, this->maxLinksPerNode ); return ConstPortsType( this->links.getData(), inputIndex, this->portsMaxCount );
} }
......
ADD_SUBDIRECTORY( core ) ADD_SUBDIRECTORY( core )
ADD_SUBDIRECTORY( graphs ) ADD_SUBDIRECTORY( networks )
ADD_SUBDIRECTORY( matrices ) ADD_SUBDIRECTORY( matrices )
ADD_SUBDIRECTORY( mesh ) ADD_SUBDIRECTORY( mesh )
ADD_SUBDIRECTORY( operators ) ADD_SUBDIRECTORY( operators )
......
/***************************************************************************
tnlEllpackGraphTester.h - description
-------------------
begin : Sep 10, 2015
copyright : (C) 2015 by Tomas Oberhuber et al.
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TNLELLPACKGRAPHTESTER_H
#define TNLELLPACKGRAPHTESTER_H
#endif /* TNLELLPACKGRAPHTESTER_H */
/*************************************************************************** /***************************************************************************
tnlEllpackGraphTest.cpp - description tnlEllpackNetworkTest.cpp - description
------------------- -------------------
begin : Sep 10, 2015 begin : Sep 10, 2015
copyright : (C) 2015 by Tomas Oberhuber copyright : (C) 2015 by Tomas Oberhuber
...@@ -19,16 +19,17 @@ ...@@ -19,16 +19,17 @@
#include <core/tnlHost.h> #include <core/tnlHost.h>
#include <cstdlib> #include <cstdlib>
#include "graphs/tnlEllpackGraph.h" #include "networks/tnlEllpackNetwork.h"
#include "networks/tnlSparseNetworkTester.h"
#include "../tnlUnitTestStarter.h" #include "../tnlUnitTestStarter.h"
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
#ifdef HAVE_CPPUNIT #ifdef HAVE_CPPUNIT
if( ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlEllpackMatrix< float, tnlHost, int > > >() || if( ! tnlUnitTestStarter :: run< tnlSparseNetworkTester< tnlEllpackNetwork< float, tnlHost, int > > >() ||
! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlEllpackMatrix< double, tnlHost, int > > >() || ! tnlUnitTestStarter :: run< tnlSparseNetworkTester< tnlEllpackNetwork< double, tnlHost, int > > >() ||
! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlEllpackMatrix< float, tnlHost, long int > > >() || ! tnlUnitTestStarter :: run< tnlSparseNetworkTester< tnlEllpackNetwork< float, tnlHost, long int > > >() ||
! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlEllpackMatrix< double, tnlHost, long int > > >() ! tnlUnitTestStarter :: run< tnlSparseNetworkTester< tnlEllpackNetwork< double, tnlHost, long int > > >()
) )
return EXIT_FAILURE; return EXIT_FAILURE;
return EXIT_SUCCESS; return EXIT_SUCCESS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment