| 1503 | } |
| 1504 | |
| 1505 | void VanitySearch::FindKeyGPU(TH_PARAM *ph) { |
| 1506 | |
| 1507 | bool ok = true; |
| 1508 | |
| 1509 | #ifdef WITHGPU |
| 1510 | |
| 1511 | // Global init |
| 1512 | int thId = ph->threadId; |
| 1513 | GPUEngine g(ph->gridSizeX,ph->gridSizeY, ph->gpuId, maxFound, (rekey!=0)); |
| 1514 | int nbThread = g.GetNbThread(); |
| 1515 | Point *p = new Point[nbThread]; |
| 1516 | Int *keys = new Int[nbThread]; |
| 1517 | vector<ITEM> found; |
| 1518 | |
| 1519 | printf("GPU: %s\n",g.deviceName.c_str()); |
| 1520 | |
| 1521 | counters[thId] = 0; |
| 1522 | |
| 1523 | getGPUStartingKeys(thId, g.GetGroupSize(), nbThread, keys, p); |
| 1524 | |
| 1525 | g.SetSearchMode(searchMode); |
| 1526 | g.SetSearchType(searchType); |
| 1527 | if (onlyFull) { |
| 1528 | g.SetPrefix(usedPrefixL,nbPrefix); |
| 1529 | } else { |
| 1530 | if(hasPattern) |
| 1531 | g.SetPattern(inputPrefixes[0].c_str()); |
| 1532 | else |
| 1533 | g.SetPrefix(usedPrefix); |
| 1534 | } |
| 1535 | |
| 1536 | getGPUStartingKeys(thId, g.GetGroupSize(), nbThread, keys, p); |
| 1537 | ok = g.SetKeys(p); |
| 1538 | ph->rekeyRequest = false; |
| 1539 | |
| 1540 | ph->hasStarted = true; |
| 1541 | |
| 1542 | // GPU Thread |
| 1543 | while (ok && !endOfSearch) { |
| 1544 | |
| 1545 | if (ph->rekeyRequest) { |
| 1546 | getGPUStartingKeys(thId, g.GetGroupSize(), nbThread, keys, p); |
| 1547 | ok = g.SetKeys(p); |
| 1548 | ph->rekeyRequest = false; |
| 1549 | } |
| 1550 | |
| 1551 | // Call kernel |
| 1552 | ok = g.Launch(found); |
| 1553 | |
| 1554 | for(int i=0;i<(int)found.size() && !endOfSearch;i++) { |
| 1555 | |
| 1556 | ITEM it = found[i]; |
| 1557 | checkAddr(*(prefix_t *)(it.hash), it.hash, keys[it.thId], it.incr, it.endo, it.mode); |
| 1558 | |
| 1559 | } |
| 1560 | |
| 1561 | if (ok) { |
| 1562 | for (int i = 0; i < nbThread; i++) { |