本文整理汇总了C++中Computer::add_In方法的典型用法代码示例。如果您正苦于以下问题:C++ Computer::add_In方法的具体用法?C++ Computer::add_In怎么用?C++ Computer::add_In使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::add_In方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_crossedIndividuals
ErrCode Crossover::get_crossedIndividuals(Individuals& crossedIndividuals, Individuals& individuals, const Device& device)
{
ErrCode err = 0;
// Параметры
int nThread_in_Warp = device.nMaxThread_in_Warp;
int nThread_in_Group = nThread_in_Warp * nWarp_in_Group;
int nThread = nThread_in_Group * nGroup_in_CU * device.max_compute_units;
// Локальные
int loc_sample_ByteSize = sampleIndividual.nByte_in_Chromoset;
int loc_sampleInvert_ByteSize = sampleIndividual.nByte_in_Chromoset;
int nIndividual_in_Loc = (device.LDS_ByteSize / nGroup_in_CU - loc_sample_ByteSize - loc_sampleInvert_ByteSize) / (sizeof(int)+sampleIndividual.nByte_in_Chromoset);
int loc_indexes_ByteSize = nIndividual_in_Loc * sizeof(int);
int loc_Individuals_ByteSize = nIndividual_in_Loc * sampleIndividual.nByte_in_Chromoset;
int loc_ByteSize = loc_sample_ByteSize + loc_sampleInvert_ByteSize + loc_indexes_ByteSize + loc_Individuals_ByteSize;
Editor editor;
err = editor.import_(kernel_filePath);
if (err != 0) return err;
editor.replace("$$EXPRESSION", expression);
calc_nParent();
editor.replace("$$N_PARENT", intToString(nParent));
editor.replace("$$N_CHROMOSECTOR_IN_CHROMOSET", intToString(sampleIndividual.chromoSectors.size()));
editor.replace("$$N_CHROMOSET_IN_LOC", intToString(nIndividual_in_Loc));
editor.replace("$$N_CHROMOSET_IN_GLOB", intToString(individuals.size()-10));
int min_rating = (*(--individuals.end())).second.rating;
editor.replace("$$START_RATING", intToString(min_rating));
editor.replace("$$N_GLOBAL_CICLES", intToString(nGlobal_Cicles));
editor.replace("$$N_LOCAL_CICLES", intToString(nLocal_Cicles));
editor.replace("$$K_RATING", floatToString(kRating));
editor.replace("$$KOEF_A", intToString(15678));
editor.replace("$$KOEF_C", intToString(34302));
editor.expand("$$EXTRACT_N_PARENT", nParent);
editor.export_(kernel_filePath + KERNEL_FILE_SUFFIX);
std::string kernel_Source;
editor.get_string(kernel_Source);
editor.clear();
Computer computer;
computer.set_Device(device);
computer.set_Kernel_Name("crossing");
computer.set_Kernel_Source(kernel_Source);
computer.set_nThread_in_Group(nThread_in_Group);
computer.set_nThread(nThread);
// Строим (компиляция ядра, создание контекста...)
err = computer.build_kernel();
if (err != 0) return err;
DataIn dataIn;
err = get_DataIn_from_Individuals(dataIn, individuals);
// Входа
computer.add_In(dataIn.chromoSectors);
computer.add_In(sampleIndividual.chromoSectors);
computer.add_In(sampleIndividual.invertChromoSectors);
computer.add_Local(loc_ByteSize);
DataOut dataOut(nThread, nParent);
// Выхода
computer.add_Out(dataOut.glob_indexes);
computer.add_Out(dataOut.ratings);
computer.add_Out(dataOut.c11s);
computer.add_Out(dataOut.c01s);
// Запускаем
computer.compute();
// Восстанавливаем особей
err = get_Individuals_from_DataOut(crossedIndividuals, dataOut);
computeTime = computer.get_computeTime();
// Освобождение ресурсов
computer.clear();
return 0;
}