// file: $isip/class/asr/Splitter/Splitter.h // version: $Id: Splitter.h 10636 2007-01-26 22:18:09Z tm334 $ // // make sure definitions are only made once // #ifndef ISIP_SPLITTER #define ISIP_SPLITTER #ifndef ISIP_STRING #include #endif #ifndef ISIP_VECTOR #include #endif #ifndef ISIP_VECTOR_DOUBLE #include #endif #ifndef ISIP_FILENAME #include #endif #ifndef ISIP_SINGLE_LINKED_LIST #include #endif #ifndef ISIP_SDB #include #endif #ifndef ISIP_NAME_MAP #include #endif #ifndef ISIP_MACHINE_DATABASE #include #endif // Splitter: a class used to split a file list and launch jobs on machines // class Splitter { //-------------------------------------------------------------------------- // // public constants // //-------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum SPLIT_MODE { NONE = 0, SPEED, MEMORY, DEF_SPLIT_MODE = NONE }; // define the static NameMap objects // static const NameMap SPLIT_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_SPLIT_MODE; static const String PARAM_MACHINE_DATABASE; static const String PARAM_CLUSTER_EMPIRE; static const String PARAM_CLUSTER_MAVERICK; static const String PARAM_CLUSTER_TALUS; //---------------------------------------- // // default values and arguments // //---------------------------------------- //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // declare the split mode // SPLIT_MODE split_mode_d; // declare the machine database // MachineDatabase mdb_d; // declare a static debug level for all class instantiations // static Integral::DEBUG debug_level_d; // a static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } static bool8 diagnose(Integral::DEBUG debug_level); // debug methods // bool8 debug(const unichar* msg) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG arg) { debug_level_d = arg; return true; } // method: destructor // ~Splitter() { clear(); } // method: default constructor // Splitter(); // method: copy constructor // Splitter(const Splitter& arg) { assign(arg); } // method: assign // bool8 assign(const Splitter& arg); // method: sofSize // int32 sofSize() const { return mdb_d.sofSize(); } // method: read // bool8 read(Sof& sof, int32 tag) { return read(sof, tag, name()); } // other read methods // bool8 read(Sof& sof, int32 tag, const String& name); bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: write // bool8 write(Sof& sof, int32 tag) const { return write(sof, tag, name()); } // other write methods // bool8 write(Sof& sof, int32 tag, const String& name) const; bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const Splitter& arg) const; // method: new // static void* operator new(size_t arg) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t arg) { return mgr_d.getBlock(arg); } // method: delete // static void operator delete(void* arg) { mgr_d.release(arg); } // method: delete[] // static void operator delete[](void* arg) { mgr_d.releaseBlock(arg); } // method: setGrowSize // static bool8 setGrowSize(int32 arg) { return mgr_d.setGrow(arg); } // method: clear // bool8 clear(Integral::CMODE cmode = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: getSplitMode // SPLIT_MODE getSplitMode() { return split_mode_d; } // method: setSplitMode // bool8 setSplitMode(SPLIT_MODE arg) { return (split_mode_d = arg); } // method: getMachineDatabase // MachineDatabase& getMachineDatabase() { return mdb_d; } // method: setMachineDatabase // bool8 setMachineDatabase(MachineDatabase& arg) { return mdb_d.assign(arg); } // method to divide the main utterance list // bool8 divideAndConquer(Filename& identifier_file, Filename& machine_list, Vector >& items); // method to generate the divided utterance lists // bool8 createUtterLists(Filename& identifier_file, Filename& identifier_list, Filename& machine_list, Filename& accumulator_list, Vector >& items, Vector& identifier_lookup, Vector& machine_lookup, Vector& accumulator_lookup); // method to split a list of jobs and submit it to the cluster // bool8 splitJobList(Filename& input_file, Filename& cpus, String& command_to_execute, String& walltime, String& batch_command, Sdb& sdb_list, String& cluster_name); // method to poll all the log files created by PBS // bool8 pollLogFile(Vector& log_files); // method to accumulate all the log files created by PBS // bool8 waitAndAccumulate(Vector& log_files, String& proc_id_str); // method to send email after the job completion // bool8 sendEmail(Long& start_time, Long& finish_time, String& begin_time, String& end_time, String& proc_id_str); // method to get the difference between two times // String getDiffTime(Long& start_time, Long& finish_time); // method to generate script file // bool8 generateScript(File& scripts_file, String& scripts_filename, String& out_scripts, String& clustername, int list_length, int reminder_list, Filename& inputfile, Sdb& sdb_list, int32 job_index, String& command_to_execute, String& wall_time); // method to generate the command for job submission // bool8 generateCommand(String& log_filename, String& scripts_filename, String& command, String& cluster_name); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; //end of include file // #endif