<commit_before>/*
 * Copyright 2011 <NAME> <<EMAIL>>
 *
 * This file is part of cphVB.
 *
 * cphVB 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.
 *
 * cphVB 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 cphVB.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <cphvb.h>
#include "InstructionSchedulerSimple.hpp"

InstructionSchedulerSimple::InstructionSchedulerSimple(
    DataManager* dataManager_,
    KernelGenerator* kernelGenerator_) :
    dataManager(dataManager_),
    kernelGenerator(kernelGenerator_){}

void InstructionSchedulerSimple::schedule(cphVBInstruction* inst)
{
    switch (inst->opcode)
    {
    case CPHVB_RELEASE:
        dataManager->release(inst->operand[0]);
        break;
    case CPHVB_SYNC:
        dataManager->sync(inst->operand[0]);
        break;
    case CPHVB_DISCARD:
        dataManager->discard(inst->operand[0]);
        break;
    default:
#ifdef DEBUG
    std::cout << "[VE CUDA] InstructionSchedulerSimple::schedule(" <<  
        cphvb_opcode_text(inst->opcode) << " ," << 
        inst->operand[0]  << " ," << 
        inst->operand[1]  << " ," << 
        inst->operand[2]  << ")" << std::endl;
#endif
        Threads threads = cphvb_nelements(inst->operand[0]->ndim, 
                                          inst->operand[0]->shape);
        BatchTable::iterator biter = batchTable.find(threads);
        if (biter != batchTable.end())
        {
            biter->second->add(inst);
        }
        else
        {
            InstructionBatchSimple* newBatch = 
                new InstructionBatchSimple(threads, dataManager, 
                                           kernelGenerator);
            newBatch->add(inst);
            batchTable[threads] = newBatch;                
        }
    }
}

void InstructionSchedulerSimple::schedule(cphvb_intp instructionCount,
                                         cphVBInstruction* instructionList)
{

    for (cphvb_intp i = 0; i < instructionCount; ++i)<commit_msg>Now ignores instructions for zero #elements<commit_after>/*
 * Copyright 2011 <NAME> <<EMAIL>>
 *
 * This file is part of cphVB.
 *
 * cphVB 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.
 *
 * cphVB 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 cphVB.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <cphvb.h>
#include "InstructionSchedulerSimple.hpp"

InstructionSchedulerSimple::InstructionSchedulerSimple(
    DataManager* dataManager_,
    KernelGenerator* kernelGenerator_) :
    dataManager(dataManager_),
    kernelGenerator(kernelGenerator_){}

void InstructionSchedulerSimple::schedule(cphVBInstruction* inst)
{
    switch (inst->opcode)
    {
    case CPHVB_RELEASE:
        dataManager->release(inst->operand[0]);
        break;
    case CPHVB_SYNC:
        dataManager->sync(inst->operand[0]);
        break;
    case CPHVB_DISCARD:
        dataManager->discard(inst->operand[0]);
        break;
    default:
#ifdef DEBUG
    std::cout << "[VE CUDA] InstructionSchedulerSimple::schedule(" <<  
        cphvb_opcode_text(inst->opcode) << " ," << 
        inst->operand[0]  << " ," << 
        inst->operand[1]  << " ," << 
        inst->operand[2]  << ")" << std::endl;
#endif
        Threads threads = cphvb_nelements(inst->operand[0]->ndim, 
                                          inst->operand[0]->shape);
        if (threads == 0)
        {
            return;
        }
        BatchTable::iterator biter = batchTable.find(threads);
        if (biter != batchTable.end())
        {
            biter->second->add(inst);
        }
        else
        {
            InstructionBatchSimple* newBatch = 
                new InstructionBatchSimple(threads, dataManager, 
                                           kernelGenerator);
            newBatch->add(inst);
            batchTable[threads] = newBatch;                
        }
    }
}

void InstructionSchedulerSimple::schedule(cphvb_intp instructionCount,
                                         cphVBInstruction* instructionList)
{

    for (cphvb_intp i = 0; i < instructionCount; ++i)
{'fraction_non_alphanumeric': 0.10578842315369262, 'fraction_numerical': 0.005788423153692615, 'mean_word_length': 2.425153793574846, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7135584', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1373, 'n_words': 374}