def run(self):
        # Go to the result folder before everything
        os.chdir(self.result_dir)

        # jobs = [(_jobID, _site)]
        # Get nodes
        # nodes = get_oar_job_nodes(_jobID, _site)

        try:
            # logger.info("Creating hostfiles for all combinations...")
            # for nbr_node in _nbrNodes:
            #     hostfile_filename = self.result_dir + '/' + 'hostfile-' + nbr_node
            #     with open(hostfile_filename, 'w') as hostfile:
            #         for node in nodes[:int(nbr_node)]:
            #             print>>hostfile, node.address

            spack_command = 'spack install -v chameleon@trunk+starpu+fxt ^starpu@svn-trunk+fxt'
            # spack_process = Remote(spack_command, nodes)
            logger.info("Starting StarPU installation...")
            spack_process = Process(spack_command).start()            

            spack_process.wait()
            logger.info("StarPU installation DONE...")
            if  (not spack_process.ok):
                logger.info("Error : " + spack_process.error_reason)
            else:
                logger.info("spac stdout: {}".format(spack_process.stdout));
            spack_process.kill()

            # Pilotage
        except:
            traceback.print_exc()
        finally:
	        logger.info("Fin...")
    def run(self):
        # Go to the result folder before everything
        os.chdir(self.result_dir)

        jobs = [(_jobID, _site)]
        # Get nodes
        nodes = get_oar_job_nodes(_jobID, _site)

        try:
            logger.info("Creating hostfiles for all combinations...")
            for nbr_node in _nbrNodes:
                hostfile_filename = self.result_dir + '/' + 'hostfile-' + nbr_node
                with open(hostfile_filename, 'w') as hostfile:
                    for node in nodes[:int(nbr_node)]:
                        print>>hostfile, node.address

            spack_process = Process('spack install -v chameleon@trunk+starpu+fxt ^starpu@svn-trunk+fxt')            
            spack_process.start()
            spack_process.wait()
            spack_process.kill()

        finally:
            logger.info("Delete job: {}".format(jobs))
            oardel(jobs)
    def run(self):
        # Go to the result folder before everything
        os.chdir(self.result_dir)

        # STARPU INSTALLATION
        spack_spec = 'chameleon@trunk+starpu+fxt ^starpu@svn-trunk+fxt'
        spack_command = 'spack install -v' + ' ' + spack_spec 
        
        logger.info("Starting StarPU installation...")
        spack_process = Process(spack_command).start()
        spack_process.wait()

        logger.info("StarPU installation DONE...")
        checkProcess(spack_process)
        spack_process.kill()

        # STARPU DIRECTORY
        logger.info("Searching and going to StarPU installation directory...")

        starpu_location_process = Process(spack_spec).start()
        starpu_location_process.wait()
        checkProcess(starpu_location)

        starpu_cd_process = Process('cd ' + starpu_location_process.stdout + '/lib/chameleon').start()
        starpu_cd_process.wait()
        checkProcess(starpu_cd_process)
        
        starpu_location_process.kill()
        starpu_cd_process.kill()

        # RUNNING EXPERIMENT
        logger.info("Starting StarPU experiment...")
        starpu_experiment_process = Process(""" export STARPU_WORKER_STATS=1
                                                export STARPU_CALIBRATE=2
                                                ./timing/time_spotrf_tile --warmup --gpus=3 --threads=9 --nb=960 --ib=96 --n_range=48000:48000:9600 """)
        starpu_experiment_process.stdout_handlers.append(self.result_dir + '/' + 'StarPU.out') # create output file for StarPU    
        starpu_experiment_process.start()
        starpu_experiment_process.wait()

        logger.info("StarPU experiment DONE...")
        checkProcess(starpu_experiment_process)        
        starpu_experiment_process.kill()
    def run(self):
        csvr = RevisionsReader(csv_file) # Launch CSV reader
        csvr_abstract = RevisionsReader(csv_file_abstract)

        os.chdir(self.result_dir) # Go to result directory before everything

        while True:
            try:
                csvr.next()
                csvr_abstract.next()

                chameleon_name = csvr_abstract.name() + '_' + csvr_abstract.chameleonBranch() + '_' + csvr_abstract.chameleonRevision() + '_' + csvr_abstract.command()
                starpu_name = csvr_abstract.name() + '_' + csvr_abstract.starpuBranch() + '_' + csvr_abstract.starpuRevision() + '_' + csvr_abstract.command()
                global_name = csvr_abstract.name() \
                                + '_chameleon_' + csvr_abstract.chameleonBranch() + '_' + csvr_abstract.chameleonRevision() \
                                + '_starpu_' + csvr_abstract.starpuBranch() + '_' + csvr_abstract.starpuRevision() \
                                + '_' + csvr_abstract.command()
                
                logger.info("Starting experiment %s" % (global_name))

                spack_spec = 'chameleon@' + chameleon_name + ' +starpu+fxt ^starpu@' + starpu_name + ' +fxt'

                # FOLDER CREATION
                folder_name = 'chameleon_' + csvr_abstract.chameleonBranch() + '_' + csvr_abstract.chameleonRevision() \
                                + '_starpu_' + csvr_abstract.starpuBranch() + '_' + csvr_abstract.starpuRevision()
                folder = self.result_dir + '/' + folder_name

                try:
                    os.mkdir(folder, 0764)
                except OSError as exc:
                    if (exc.errno != errno.EEXIST):
                        raise exc
                    pass

                # STARPU INSTALLATION
                logger.info("Starting StarPU installation")
                spack_process = Process('spack -d install' + ' ' + spack_spec)


                if (not os.path.isfile(folder + '/' + 'compil_' + folder_name)):
                    spack_process.stdout_handlers.append(folder + '/' + 'compil_' + folder_name) # create output file for StarPU installation
                spack_process.start()
                spack_process.wait()

                logger.info("StarPU installation DONE")
                is_ok = self.checkProcess(spack_process)
                spack_process.kill()

                if (not is_ok):
                    continue # stop this experiment

                # STARPU DIRECTORY
                logger.info("Searching and going to StarPU installation directory")

                starpu_location_process = Process('spack location -i' + ' ' + spack_spec).start()
                starpu_location_process.wait()
                is_ok = self.checkProcess(starpu_location_process)
            
                starpu_path = starpu_location_process.stdout.replace("\n", "") # remove end_of_line
                starpu_cd = 'cd' + ' ' + starpu_path + '/lib/chameleon/'
                starpu_location_process.kill()

                if (not is_ok):
                    continue # stop this experiment
                
                # RUNNING EXPERIMENT
                logger.info("Starting StarPU experiment")

                starpu_experiment_process = Process(starpu_cd + '\n' + csvr.command(), shell=True)
                           
                starpu_experiment_process.stdout_handlers.append(folder + '/' + 'stdout_' + global_name) # create output file for StarPU execution
                starpu_experiment_process.stderr_handlers.append(folder + '/' + 'stderr_' + global_name) # create error file for StarPU execution
                starpu_experiment_process.start()
                starpu_experiment_process.wait()

                logger.info("StarPU experiment DONE")
                is_ok = self.checkProcess(starpu_experiment_process)        
                starpu_experiment_process.kill()

                if (not is_ok):
                    continue # stop this experiment

            except StopIteration:
                break;
    def run(self):
        # Go to the result folder before everything
        os.chdir(self.result_dir)

        # OARSUB
        jobs = oarsub([(OarSubmission(resources='nodes=' + _nbrNodes.__str__(), 
                                      job_type='deploy', 
                                      walltime=_walltime, 
                                      sql_properties=_properties), _site)])
        
        job_id, site = jobs[0]
        try:
            # KADEPLOY
            logger.info("Waiting job start %s on %s" % (job_id, site))
            wait_oar_job_start(job_id, site, prediction_callback=prediction_callback)
            logger.info("getting nodes of %s on %s" % (job_id, site))
            nodes = get_oar_job_nodes(job_id, site)

            deployed, undeployed = deploy(Deployment(nodes, env_name=env_name),
                                          check_deployed_command=already_configured)
            if undeployed:
                logger.warn(
                    "NOT deployed nodes : {}".format(str(undeployed)))
                raise RuntimeError('Deployement failed')

            # STARPU INSTALLATION
            spack_spec = 'chameleon@trunk+starpu+fxt ^starpu@svn-trunk+fxt'
            spack_command = 'spack install -v' + ' ' + spack_spec 

            logger.info("Starting StarPU installation...")
            spack_process = Process(spack_command).start()
            spack_process.wait()

            logger.info("StarPU installation DONE...")
            self.checkProcess(spack_process)
            spack_process.kill()

            # STARPU DIRECTORY
            logger.info("Searching and going to StarPU installation directory...")

            starpu_location_process = Process(spack_spec).start()
            starpu_location_process.wait()
            self.checkProcess(starpu_location)

            starpu_cd_process = Process('cd ' + starpu_location_process.stdout + '/lib/chameleon').start()
            starpu_cd_process.wait()
            self.checkProcess(starpu_cd_process)

            starpu_location_process.kill()
            starpu_cd_process.kill()

            # RUNNING EXPERIMENT
            logger.info("Starting StarPU experiment...")
            starpu_experiment_process = Process(""" export STARPU_WORKER_STATS=1
                                                    export STARPU_CALIBRATE=2
                                                    ./timing/time_spotrf_tile --warmup --gpus=3 --threads=9 --nb=960 --ib=96 --n_range=48000:48000:9600 """)
            starpu_experiment_process.stdout_handlers.append(self.result_dir + '/' + 'StarPU.out') # create output file for StarPU    
            starpu_experiment_process.start()
            starpu_experiment_process.wait()

            logger.info("StarPU experiment DONE...")
            self.checkProcess(starpu_experiment_process)        
            starpu_experiment_process.kill()

        finally:
	        logger.info("Delete job : {}".format(jobs))
            oardel(jobs)