void monteCarloKernel (int n, float* samplePrices, float* sampleWeights, float dt, mt19937state* randStates, monteCarloOptionStruct optionStruct) { int i; #pragma acc data copyin (randStates[0:n]), copyout (samplePrices[0:n], sampleWeights[0:n]) { #pragma acc kernels pcopyin (randStates[0:n]), pcopyout (samplePrices[0:n], sampleWeights[0:n]) { #pragma acc loop independent for (i = 0; i < n; ++i) { float path[SEQUENCE_LENGTH]; initializePath (path); int optionStructNum = 0; getPath (path, i, dt, randStates, optionStruct); float price = getPrice (path [SEQUENCE_LENGTH-1]); samplePrices [i] = price; sampleWeights [i] = DEFAULT_SEQ_WEIGHT; } } } }
void Field::setPath(word character_offset, word target_coord_xw, word target_coord_yw, bool use_alternative) { if (option->game_type != GAME_NANPA2) { return; } if (is_path_found) { is_path_found = false; return; } word character_coord_xw = data->queryWord(character_offset + CHARACTER_COORD_XW); word character_coord_yw = data->queryWord(character_offset + CHARACTER_COORD_YW); word start_offset = calculatePathOffset(character_coord_xw, character_coord_yw); word target_offset = calculatePathOffset(target_coord_xw, target_coord_yw); // initialize path initializePath(character_offset); if (data->queryByte(target_offset) != PATH_MARK_CLOSED) { data->writeByte(start_offset, PATH_MARK_CHARACTER); if ((generatePath(character_offset, target_coord_xw, target_coord_yw, PATH_MARK_INITIAL, PATH_SEQUENCE_DEFAULT) == false)) { data->writeByte(start_offset, PATH_MARK_CLOSED); } //TODO: remove this //DUMPPATH; if (data->queryByte(target_offset) < PATH_MARK_OPENED) { is_path_found = true; return; } } if (use_alternative) { //TODO: implement alternative pathfinding method } is_path_found = false; return; }
void monteCarloKernelCpu(int n, float* samplePrices, float* sampleWeights, float dt, mt19937state* randStates, monteCarloOptionStruct optionStruct) { int i; for (i = 0; i < n; ++i) { float path[SEQUENCE_LENGTH]; initializePath (path); int optionStructNum = 0; getPath (path, i, dt, randStates, optionStruct); float price = getPrice (path [SEQUENCE_LENGTH-1]); samplePrices [i] = price; sampleWeights [i] = DEFAULT_SEQ_WEIGHT; } }