Loading src/RayTraceStructures.cpp +0 −181 Original line number Diff line number Diff line Loading @@ -1914,120 +1914,6 @@ void RayTrace::intensity_struct::swap( RayTrace::intensity_struct &rhs ) } /****************************************************************** * Constructors/Destructors for tree_struct * ******************************************************************/ RayTrace::tree_struct::tree_struct() { level = -1; a = NULL; b = NULL; } RayTrace::tree_struct::~tree_struct() { delete a; a = NULL; delete b; b = NULL; level = -1; } bool RayTrace::tree_struct::operator==( const RayTrace::tree_struct &rhs ) const { if ( level != rhs.level ) return false; if ( ( a == NULL ) != ( rhs.a == NULL ) || ( b == NULL ) != ( rhs.b == NULL ) ) return false; if ( a != NULL ) { if ( ( *a ) != ( *rhs.a ) ) return false; } if ( b != NULL ) { if ( ( *b ) != ( *rhs.b ) ) return false; } return true; } int RayTrace::tree_struct::depth() const { int d = 0; if ( a != NULL ) { d = std::max( d, a->depth() ); }; if ( b != NULL ) { d = std::max( d, b->depth() ); }; return d + 1; } int RayTrace::tree_struct::nodes() const { int n = 1; if ( a != NULL ) { n += a->nodes(); }; if ( b != NULL ) { n += b->nodes(); }; return n; } /********************************************************************** * Function to convert tree structure to a byte array * * Note that we do not want to include a byte array header for the * * tree structure as this will significantly increase the memory * * requirements (by a factor of 2.3x). * **********************************************************************/ std::pair<char *, size_t> RayTrace::tree_struct::pack() const { // Convert the leaves of the tree to byte arrays std::pair<char *, size_t> data_a( (char *) NULL, 0 ); std::pair<char *, size_t> data_b( (char *) NULL, 0 ); if ( a != NULL ) data_a = a->pack(); if ( b != NULL ) data_b = b->pack(); size_t N_bytes = data_a.second + data_b.second + 3 * sizeof( int ); char *data = new char[N_bytes]; // Store the tree int *data_int = (int *) data; data_int[0] = level; data_int[1] = static_cast<int>( data_a.second ); data_int[2] = static_cast<int>( data_b.second ); char *data_char = (char *) &data_int[3]; memcpy( &data_char[0], data_a.first, data_a.second ); memcpy( &data_char[data_a.second], data_b.first, data_b.second ); delete[] data_a.first; delete[] data_b.first; return std::pair<char *, size_t>( data, N_bytes ); } /********************************************************************** * Function to unpack the tree structure * **********************************************************************/ void RayTrace::tree_struct::unpack( std::pair<const char *, size_t> data ) { delete a; a = NULL; delete b; b = NULL; int *data_int = (int *) data.first; level = data_int[0]; int N_bytes_a = data_int[1]; int N_bytes_b = data_int[2]; char *data_a = (char *) &data_int[3]; char *data_b = &data_a[N_bytes_a]; if ( N_bytes_a > 0 ) { a = new tree_struct; a->unpack( std::pair<char *, size_t>( data_a, N_bytes_a ) ); } if ( N_bytes_b > 0 ) { b = new tree_struct; b->unpack( std::pair<char *, size_t>( data_b, N_bytes_b ) ); } } /********************************************************************** * Constructors/Destructors for ray_gain_struct * **********************************************************************/ Loading Loading @@ -2405,70 +2291,3 @@ void RayTrace::create_image_struct::unpack( std::pair<const char *, size_t> data } /********************************************************************** * load_balance_struct * **********************************************************************/ RayTrace::load_balance_struct::load_balance_struct() { comm = MPI_COMM_WORLD; size = MPI_size( comm ); rank = MPI_rank( comm ); J = -1; sync_N_pop = false; proc_zone = NULL; N_start = 0; N_parallel = 1; } RayTrace::load_balance_struct::load_balance_struct( int J_ ) { comm = MPI_COMM_WORLD; size = MPI_size( comm ); rank = MPI_rank( comm ); J = J_; sync_N_pop = false; proc_zone = new int[J]; for ( int i = 0; i < J; i++ ) proc_zone[i] = i % size; N_start = 0; N_parallel = 1; } RayTrace::load_balance_struct::~load_balance_struct() { delete[] proc_zone; } bool RayTrace::load_balance_struct::valid( int J0, int rad_type, const bool *ii ) const { int rank0 = MPI_rank( comm ); int size0 = MPI_size( comm ); if ( rank != rank0 || size != size0 ) { char tmp[100]; sprintf( tmp, " rank = %i, size = %i, load_balance = %i, %i\n", rank0, size0, rank, size ); perr << "Error, load_balance information does not match MPI rank or size\n" << tmp; return false; } if ( size > 1 ) { // Check that the load balance information exists if ( proc_zone == NULL || J != J0 ) { perr << "Error, multiple processors are used but load_balance is not properly filled\n"; return false; } // Check that the load balance information is set correctly if ( rad_type == 4 ) { // Note: Parallel processing of the atomic populations is not currently supported for // full radiation transport for ( int i = 0; i < J; i++ ) { if ( proc_zone[i] != 0 ) { perr << "Error, full radiation transport is used, processor 0 must perform all " "atomic calculations\n"; return false; } } } else { for ( int i = 0; i < J; i++ ) { if ( ii[i] && ( proc_zone[i] < 0 || proc_zone[i] >= size ) ) { perr << "Error, no processor owns the current zone\n"; return false; } } } } return true; } src/RayTraceStructures.h +0 −58 Original line number Diff line number Diff line Loading @@ -467,64 +467,6 @@ private: }; //! Structure used to identify recursion tree for calc_step struct tree_struct { int level; //!< Current level of the tree tree_struct *a; //!< The first step of the recursion tree_struct *b; //!< The second step of the recursion //! Constructor used to initialize key values tree_struct(); //! De-constructor ~tree_struct(); /*! * This function converts the data structure (for a single length) to a byte array. * It returns the byte array and number of bytes used. */ std::pair<char *, size_t> pack() const; //! This function converts a byte array to fill the data structure. void unpack( std::pair<const char *, size_t> data ); //! Comparison operator bool operator==( const tree_struct &rhs ) const; //! operator!= inline bool operator!=( const tree_struct &rhs ) const { return !( this->operator==( rhs ) ); } //! Get the maximum depth of the tree int depth() const; //! Get the total number of nodes of the tree int nodes() const; protected: tree_struct( const tree_struct & ); // Private copy constructor tree_struct &operator=( const tree_struct & ); // Private assignment operator }; //! Structure used to contain information about the load balancing struct load_balance_struct { bool sync_N_pop; //!< Do we want to syncronize N_ion and N_meta across all processors int size; //!< The number of processors int rank; //!< The rank of the current processor int J; //!< The number of zones (should match plasma.J) int *proc_zone; //!< Which processor is in charge of which zone (1xJ) int N_start; //!< First ray to process (set to 0 for domain based decompoisition, //!< otherwise set to a unique number for each thread) int N_parallel; //!< Number of rays processed in parallel (set to 0 for domain based //! decompoisition, otherwise set to the number of threads) MPI_Comm comm; //!< Communicator to use //! Empty constructor load_balance_struct(); //! Constructor used to initialize key values explicit load_balance_struct( int J ); //! Destructor ~load_balance_struct(); //! Check that the load balance data is valid bool valid( int J, int rad_type, const bool *ii ) const; protected: load_balance_struct( const load_balance_struct & ); // Private copy constructor load_balance_struct &operator=( const load_balance_struct & ); // Private assignment operator }; // Structure to contain extra information for byte arrays (helps to allow for future versions) struct byte_array_header { unsigned char id; // Special number to determine if the header was used Loading Loading
src/RayTraceStructures.cpp +0 −181 Original line number Diff line number Diff line Loading @@ -1914,120 +1914,6 @@ void RayTrace::intensity_struct::swap( RayTrace::intensity_struct &rhs ) } /****************************************************************** * Constructors/Destructors for tree_struct * ******************************************************************/ RayTrace::tree_struct::tree_struct() { level = -1; a = NULL; b = NULL; } RayTrace::tree_struct::~tree_struct() { delete a; a = NULL; delete b; b = NULL; level = -1; } bool RayTrace::tree_struct::operator==( const RayTrace::tree_struct &rhs ) const { if ( level != rhs.level ) return false; if ( ( a == NULL ) != ( rhs.a == NULL ) || ( b == NULL ) != ( rhs.b == NULL ) ) return false; if ( a != NULL ) { if ( ( *a ) != ( *rhs.a ) ) return false; } if ( b != NULL ) { if ( ( *b ) != ( *rhs.b ) ) return false; } return true; } int RayTrace::tree_struct::depth() const { int d = 0; if ( a != NULL ) { d = std::max( d, a->depth() ); }; if ( b != NULL ) { d = std::max( d, b->depth() ); }; return d + 1; } int RayTrace::tree_struct::nodes() const { int n = 1; if ( a != NULL ) { n += a->nodes(); }; if ( b != NULL ) { n += b->nodes(); }; return n; } /********************************************************************** * Function to convert tree structure to a byte array * * Note that we do not want to include a byte array header for the * * tree structure as this will significantly increase the memory * * requirements (by a factor of 2.3x). * **********************************************************************/ std::pair<char *, size_t> RayTrace::tree_struct::pack() const { // Convert the leaves of the tree to byte arrays std::pair<char *, size_t> data_a( (char *) NULL, 0 ); std::pair<char *, size_t> data_b( (char *) NULL, 0 ); if ( a != NULL ) data_a = a->pack(); if ( b != NULL ) data_b = b->pack(); size_t N_bytes = data_a.second + data_b.second + 3 * sizeof( int ); char *data = new char[N_bytes]; // Store the tree int *data_int = (int *) data; data_int[0] = level; data_int[1] = static_cast<int>( data_a.second ); data_int[2] = static_cast<int>( data_b.second ); char *data_char = (char *) &data_int[3]; memcpy( &data_char[0], data_a.first, data_a.second ); memcpy( &data_char[data_a.second], data_b.first, data_b.second ); delete[] data_a.first; delete[] data_b.first; return std::pair<char *, size_t>( data, N_bytes ); } /********************************************************************** * Function to unpack the tree structure * **********************************************************************/ void RayTrace::tree_struct::unpack( std::pair<const char *, size_t> data ) { delete a; a = NULL; delete b; b = NULL; int *data_int = (int *) data.first; level = data_int[0]; int N_bytes_a = data_int[1]; int N_bytes_b = data_int[2]; char *data_a = (char *) &data_int[3]; char *data_b = &data_a[N_bytes_a]; if ( N_bytes_a > 0 ) { a = new tree_struct; a->unpack( std::pair<char *, size_t>( data_a, N_bytes_a ) ); } if ( N_bytes_b > 0 ) { b = new tree_struct; b->unpack( std::pair<char *, size_t>( data_b, N_bytes_b ) ); } } /********************************************************************** * Constructors/Destructors for ray_gain_struct * **********************************************************************/ Loading Loading @@ -2405,70 +2291,3 @@ void RayTrace::create_image_struct::unpack( std::pair<const char *, size_t> data } /********************************************************************** * load_balance_struct * **********************************************************************/ RayTrace::load_balance_struct::load_balance_struct() { comm = MPI_COMM_WORLD; size = MPI_size( comm ); rank = MPI_rank( comm ); J = -1; sync_N_pop = false; proc_zone = NULL; N_start = 0; N_parallel = 1; } RayTrace::load_balance_struct::load_balance_struct( int J_ ) { comm = MPI_COMM_WORLD; size = MPI_size( comm ); rank = MPI_rank( comm ); J = J_; sync_N_pop = false; proc_zone = new int[J]; for ( int i = 0; i < J; i++ ) proc_zone[i] = i % size; N_start = 0; N_parallel = 1; } RayTrace::load_balance_struct::~load_balance_struct() { delete[] proc_zone; } bool RayTrace::load_balance_struct::valid( int J0, int rad_type, const bool *ii ) const { int rank0 = MPI_rank( comm ); int size0 = MPI_size( comm ); if ( rank != rank0 || size != size0 ) { char tmp[100]; sprintf( tmp, " rank = %i, size = %i, load_balance = %i, %i\n", rank0, size0, rank, size ); perr << "Error, load_balance information does not match MPI rank or size\n" << tmp; return false; } if ( size > 1 ) { // Check that the load balance information exists if ( proc_zone == NULL || J != J0 ) { perr << "Error, multiple processors are used but load_balance is not properly filled\n"; return false; } // Check that the load balance information is set correctly if ( rad_type == 4 ) { // Note: Parallel processing of the atomic populations is not currently supported for // full radiation transport for ( int i = 0; i < J; i++ ) { if ( proc_zone[i] != 0 ) { perr << "Error, full radiation transport is used, processor 0 must perform all " "atomic calculations\n"; return false; } } } else { for ( int i = 0; i < J; i++ ) { if ( ii[i] && ( proc_zone[i] < 0 || proc_zone[i] >= size ) ) { perr << "Error, no processor owns the current zone\n"; return false; } } } } return true; }
src/RayTraceStructures.h +0 −58 Original line number Diff line number Diff line Loading @@ -467,64 +467,6 @@ private: }; //! Structure used to identify recursion tree for calc_step struct tree_struct { int level; //!< Current level of the tree tree_struct *a; //!< The first step of the recursion tree_struct *b; //!< The second step of the recursion //! Constructor used to initialize key values tree_struct(); //! De-constructor ~tree_struct(); /*! * This function converts the data structure (for a single length) to a byte array. * It returns the byte array and number of bytes used. */ std::pair<char *, size_t> pack() const; //! This function converts a byte array to fill the data structure. void unpack( std::pair<const char *, size_t> data ); //! Comparison operator bool operator==( const tree_struct &rhs ) const; //! operator!= inline bool operator!=( const tree_struct &rhs ) const { return !( this->operator==( rhs ) ); } //! Get the maximum depth of the tree int depth() const; //! Get the total number of nodes of the tree int nodes() const; protected: tree_struct( const tree_struct & ); // Private copy constructor tree_struct &operator=( const tree_struct & ); // Private assignment operator }; //! Structure used to contain information about the load balancing struct load_balance_struct { bool sync_N_pop; //!< Do we want to syncronize N_ion and N_meta across all processors int size; //!< The number of processors int rank; //!< The rank of the current processor int J; //!< The number of zones (should match plasma.J) int *proc_zone; //!< Which processor is in charge of which zone (1xJ) int N_start; //!< First ray to process (set to 0 for domain based decompoisition, //!< otherwise set to a unique number for each thread) int N_parallel; //!< Number of rays processed in parallel (set to 0 for domain based //! decompoisition, otherwise set to the number of threads) MPI_Comm comm; //!< Communicator to use //! Empty constructor load_balance_struct(); //! Constructor used to initialize key values explicit load_balance_struct( int J ); //! Destructor ~load_balance_struct(); //! Check that the load balance data is valid bool valid( int J, int rad_type, const bool *ii ) const; protected: load_balance_struct( const load_balance_struct & ); // Private copy constructor load_balance_struct &operator=( const load_balance_struct & ); // Private assignment operator }; // Structure to contain extra information for byte arrays (helps to allow for future versions) struct byte_array_header { unsigned char id; // Special number to determine if the header was used Loading