int main() { int array[5]; int array_length; array_length = sizeof(array) / sizeof(int); scanArray(array, array_length); invertArray(array, array_length); sortArray(array, array_length); printf("\n"); return(0); }
char* SExpression::scan(char* head, char* tail, SExpression* expression) { if (expression) expression->head_ = expression->tail_ = 0; char* s = skipWhitespace(head, tail); if (s < tail) { switch(*s) { case '(': s = scanArray(s, tail, expression); break; default: s = scanRawString(s, tail, expression); break; } s = skipWhitespace(s, tail); } return s; }
int main(int argc, char** argv) { cuInit(0); DevicePtr device; CUresult result = CreateCuDevice(0, &device); ContextPtr context; result = CreateCuContext(device, 0, &context); scanEngine_t engine; scanStatus_t status = scanCreateEngine( "../../src/mgpuscan/globalscan.cubin", &engine); int count = 1<< 19; std::vector<int> vals(count); std::tr1::uniform_int<int> r(0, 15); for(int i(0); i < count; ++i) vals[i] = r(mt19937); DeviceMemPtr deviceMem; result = context->MemAlloc(vals, &deviceMem); uint scanTotal; status = scanArray(engine, deviceMem->Handle(), count, &scanTotal, false); std::vector<int> deviceScan; deviceMem->ToHost(deviceScan); std::vector<int> hostScan(count); for(int i(1); i < count; ++i) { hostScan[i] = hostScan[i - 1] + vals[i - 1]; } scanDestroyEngine(engine); bool success = hostScan == deviceScan; if(success) printf("Global scan success.\n"); else printf("Global scan failure.\n"); return 0; }
int main () { int userSize; printf( "Input size of an array: " ); scanf( "%d", & userSize ); if ( userSize <= 0 ) { printf( "Expected a positive size\n" ); return -1; } int * pData = new int[ userSize ]; printf( "Input %d integer elements: \n", userSize ); scanArray( pData, userSize ); reverseArray( pData, userSize ); printArray( pData, userSize ); delete[] pData; return 0; }