// Returns a bigger MATRIX with a new column and row in the matrix in order // to split the blob at the given (ind,ind) diagonal location. // Entries are relocated to the new MATRIX using the transformation defined // by MATRIX_COORD::MapForSplit. // Transfers the pointer data to the new MATRIX and deletes *this. MATRIX* MATRIX::ConsumeAndMakeBigger(int ind) { int dim = dimension(); int band_width = bandwidth(); // Check to see if bandwidth needs expanding. for (int col = ind; col >= 0 && col > ind - band_width; --col) { if (array_[col * band_width + band_width - 1] != empty_) { ++band_width; break; } } MATRIX* result = new MATRIX(dim + 1, band_width); for (int col = 0; col < dim; ++col) { for (int row = col; row < dim && row < col + bandwidth(); ++row) { MATRIX_COORD coord(col, row); coord.MapForSplit(ind); BLOB_CHOICE_LIST* choices = get(col, row); if (choices != NULL) { // Correct matrix location on each choice. BLOB_CHOICE_IT bc_it(choices); for (bc_it.mark_cycle_pt(); !bc_it.cycled_list(); bc_it.forward()) { BLOB_CHOICE* choice = bc_it.data(); choice->set_matrix_cell(coord.col, coord.row); } ASSERT_HOST(coord.Valid(*result)); result->put(coord.col, coord.row, choices); } } } delete this; return result; }
int GlobalMemoryBandwidth::runCLKernels(void) { int status; if(vec3 == true) std::cout << "\nGlobal Memory Read\nAccessType\t: single\nVectorElements\t: 3" << std::endl; else std::cout << "\nGlobal Memory Read\nAccessType\t: single\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; // Measure bandwidth of single reads from global buffer status = bandwidth(kernel[0], outputBufferReadSingle, outputReadSingle); if(status != SDK_SUCCESS) return SDK_FAILURE; if(vec3 == true) std::cout << "\nGlobal Memory Read\nAccessType\t: linear\nVectorElements\t: 3" << std::endl; else std::cout << "\nGlobal Memory Read\nAccessType\t: linear\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; // Measure bandwidth of linear reads from global buffer status = bandwidth(kernel[1], outputBufferReadLinear, outputReadLinear); if(status != SDK_SUCCESS) return SDK_FAILURE; if(vec3 == true) std::cout << "\nGlobal Memory Read\nAccessType\t: linear(uncached)\nVectorElements\t: 3" << std::endl; else std::cout << "\nGlobal Memory Read\nAccessType\t: linear(uncached)\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; // Measure bandwidth of linear reads from global buffer status = bandwidth(kernel[2], outputBufferReadLU, outputReadLU); if(status != SDK_SUCCESS) return SDK_FAILURE; if(vec3 == true) std::cout << "\nGlobal Memory Write\nAccessType\t: linear\nVectorElements\t: 3" << std::endl; else std::cout << "\nGlobal Memory Write\nAccessType\t: linear\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; writeFlag = true; // Measure bandwidth of linear reads from global buffer status = bandwidth(kernel[3], outputBufferWriteLinear, outputWriteLinear); if(status != SDK_SUCCESS) return SDK_FAILURE; return SDK_SUCCESS; }
void NetworkInfoClientBlackBerry::onCurrentNetworkTypeChange(BlackBerry::Platform::InternalNetworkConnectionType) { if (m_isActive) { RefPtr<NetworkInfo> newNetworkInfo = NetworkInfo::create(bandwidth(), metered()); NetworkInfoController::from(m_webPagePrivate->m_page)->didChangeNetworkInformation(eventNames().webkitnetworkinfochangeEvent , newNetworkInfo.get()); } }
// --------------------------------------------------------------------------- // addNoiseEnergy // --------------------------------------------------------------------------- //! Add noise (bandwidth) energy to this Breakpoint by computing new //! amplitude and bandwidth values. enoise may be negative, but //! noise energy cannot be removed (negative energy added) in excess //! of the current noise energy. //! //! \param enoise is the amount of noise energy to add to //! this Breakpoint. // void Breakpoint::addNoiseEnergy( double enoise ) { // compute current energies: double e = amplitude() * amplitude(); // current total energy double n = e * bandwidth(); // current noise energy // Assert( e >= n ); // could complain, but its recoverable, just fix it: if ( e < n ) { e = n; } // guard against divide-by-zero, and don't allow // the sinusoidal energy to decrease: if ( n + enoise > 0. ) { // if new noise energy is positive, total // energy must also be positive: // Assert( e + enoise > 0 ); setBandwidth( (n + enoise) / (e + enoise) ); setAmplitude( std::sqrt(e + enoise) ); } else { // if new noise energy is negative, leave // all sinusoidal energy: setBandwidth( 0. ); setAmplitude( std::sqrt( e - n ) ); } }
void NetworkInfoClientBlackBerry::onCurrentCellularTypeChange(BlackBerry::Platform::InternalCellularConnectionType) { // Only dispatch to listeners if the current type is cellular. if (BlackBerry::Platform::NetworkInfo::instance()->getCurrentNetworkType() == BlackBerry::Platform::NetworkTypeCellular && m_isActive) { RefPtr<NetworkInfo> newNetworkInfo = NetworkInfo::create(bandwidth(), metered()); NetworkInfoController::from(m_webPagePrivate->m_page)->didChangeNetworkInformation(eventNames().webkitnetworkinfochangeEvent , newNetworkInfo.get()); } }
virtual std::string toString() const { std::stringstream ss; ss << Base::toString() << " fReference=" << fReference() << " strength=" << strength() << " averageStrength=" << averageStrength() << " strengthRMS=" << strengthRMS() << " bandwidth=" << bandwidth(); return ss.str(); }
static int run(void) { int i, ret; if (!opts.dst_addr) { ret = ft_start_server(); if (ret) return ret; } ret = opts.dst_addr ? ft_client_connect() : ft_server_connect(); if (ret) { return ret; } ret = ft_bw_init(); if (ret) return ret; if (!(opts.options & FT_OPT_SIZE)) { for (i = 0; i < TEST_CNT; i++) { if (!ft_use_size(i, opts.sizes_enabled)) continue; opts.transfer_size = test_size[i].size; init_test(&opts, test_name, sizeof(test_name)); ret = bandwidth(); if (ret) goto out; } } else { init_test(&opts, test_name, sizeof(test_name)); ret = bandwidth(); if (ret) goto out; } ft_finalize(); out: return ret; }
int ComputeBench::runCLKernels(void) { std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; // Measure bandwidth of uncached linear reads from global buffer int status = bandwidth(kernel[0], outputKadd, &KaddTime, &KaddGbps); if (status != SDK_SUCCESS) { return SDK_FAILURE; } return SDK_SUCCESS; }
bool proc(const Proxy::Base& p, const PowerSpectrum& ps) { try { const std::pair<double, double> fMin(cal(fReference() - 0.75*bandwidth())); const std::pair<double, double> fMax(cal(fReference() + 0.75*bandwidth())); const size_t indexBeg(ps.freq2index(fMin.first)); const size_t indexEnd(ps.freq2index(fMax.first)); double sum(0), sum2(0); size_t counter(0); for (size_t u(indexBeg); u<=indexEnd; ++u, ++counter) { sum += ps[u].second; sum2 += ps[u].second * ps[u].second; } strength_ = p.volt2dbm(sum / normWindow()); // here we do _not_ correct for window gain averageStrength_ = p.volt2dbm((counter != 0) ? sum/counter : 1.); strengthRMS_ = p.rms_dbm() - 20.*std::log10(std::sqrt((counter != 0) ? counter : 1)); // p.volt2dbm((counter != 0) ? std::sqrt(sum2/counter-averageStrength_*averageStrength_) : 1.); return true; } catch (const std::exception& e) { LOG_WARNING(e.what()); return false; } }
// Print the best guesses out of the match rating matrix. void MATRIX::print(const UNICHARSET &unicharset) const { tprintf("Ratings Matrix (top 3 choices)\n"); int dim = dimension(); int band_width = bandwidth(); int row, col; for (col = 0; col < dim; ++col) { for (row = col; row < dim && row < col + band_width; ++row) { BLOB_CHOICE_LIST *rating = this->get(col, row); if (rating == NOT_CLASSIFIED) continue; BLOB_CHOICE_IT b_it(rating); tprintf("col=%d row=%d ", col, row); for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) { tprintf("%s rat=%g cert=%g " , unicharset.id_to_unichar(b_it.data()->unichar_id()), b_it.data()->rating(), b_it.data()->certainty()); } tprintf("\n"); } tprintf("\n"); } tprintf("\n"); for (col = 0; col < dim; ++col) tprintf("\t%d", col); tprintf("\n"); for (row = 0; row < dim; ++row) { for (col = 0; col <= row; ++col) { if (col == 0) tprintf("%d\t", row); if (row >= col + band_width) { tprintf(" \t"); continue; } BLOB_CHOICE_LIST *rating = this->get(col, row); if (rating != NOT_CLASSIFIED) { BLOB_CHOICE_IT b_it(rating); int counter = 0; for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) { tprintf("%s ", unicharset.id_to_unichar(b_it.data()->unichar_id())); ++counter; if (counter == 3) break; } tprintf("\t"); } else { tprintf(" \t"); } } tprintf("\n"); } }
// Makes and returns a deep copy of *this, including all the BLOB_CHOICEs // on the lists, but not any LanguageModelState that may be attached to the // BLOB_CHOICEs. MATRIX* MATRIX::DeepCopy() const { int dim = dimension(); int band_width = bandwidth(); MATRIX* result = new MATRIX(dim, band_width); for (int col = 0; col < dim; ++col) { for (int row = col; row < dim && row < col + band_width; ++row) { BLOB_CHOICE_LIST* choices = get(col, row); if (choices != NULL) { BLOB_CHOICE_LIST* copy_choices = new BLOB_CHOICE_LIST; copy_choices->deep_copy(choices, &BLOB_CHOICE::deep_copy); result->put(col, row, copy_choices); } } } return result; }
int main(int argc, char* argv[]) { Graph* g = newGraph(0); loadGraph(g, "graph.txt"); int* result = (int*) malloc(g->nvertices * sizeof(int)); bandwidth(g,result); printf("Bandwidth: "); int i; for(i=0; i<g->nvertices; i++) { printf("%d ", result[i]); } printf("\n"); deleteGraph(g); return 0; }
int ConstantBandwidth::runCLKernels(void) { int status; if(vec3 == true) std::cout << "\nAccessType\t: single(static index)\nVectorElements\t: 3" << std::endl; else std::cout << "\nAccessType\t: single(static index)\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; // Measure bandwidth of single reads(static index) from constant buffer status = bandwidth(kernel[0]); if(status != SDK_SUCCESS) return SDK_FAILURE; if(verify) { int size = length * vectorSize * sizeof(cl_float); // Verify result for single access memset(verificationOutput, 0, size); int index = 0; for(int i = 0; i < (int)length; i++) { for(int j = 0; j < NUM_READS; j++) { for(int k = 0; k < vectorSize; k++) verificationOutput[i * vectorSize + k] += input[(index + j) * vectorSize + k]; } } if(!memcmp(output, verificationOutput, size)) { std::cout << "Passed!\n" << std::endl; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } } if(vec3 == true) std::cout << "\nAccessType\t: single(dynamic index)\nVectorElements\t: 3" << std::endl; else std::cout << "\nAccessType\t: single(dynamic index)\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; dynamiArgFlag = true; // Measure bandwidth of single(dynamic index) reads from constant buffer status = bandwidth(kernel[1]); if(status != SDK_SUCCESS) return SDK_FAILURE; if(verify) { int size = length * vectorSize * sizeof(cl_float); // Verify result for single access if(!memcmp(output, verificationOutput, size)) { std::cout << "Passed!\n" << std::endl; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } } if(vec3 == true) std::cout << "\nAccessType\t: linear\nVectorElements\t: 3" << std::endl; else std::cout << "\nAccessType\t: linear\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; dynamiArgFlag = false; // Measure bandwidth of linear reads from constant buffer status = bandwidth(kernel[2]); if(status != SDK_SUCCESS) return SDK_FAILURE; if(verify) { int size = length * vectorSize * sizeof(cl_float); memset(verificationOutput, 0, size); // Verify result for Linear access for(int i = 0; i < (int)length; i++) { int index = i % 64; for(int j = 0; j < NUM_READS; j++) { for(int k = 0; k < vectorSize; k++) { verificationOutput[i * vectorSize + k] += input[(index + j) * vectorSize + k]; } } } if(!memcmp(output, verificationOutput, size)) { std::cout << "Passed!\n" << std::endl; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } } std::cout << "\nAccessType\t: random\nVectorElements\t: " << vectorSize << std::endl; std::cout << "Bandwidth\t"; // Measure bandwidth of linear reads from constant buffer status = bandwidth(kernel[3]); if(status != SDK_SUCCESS) return SDK_FAILURE; if(verify) { int size = length * sizeof(cl_float) *vectorSize; memset(verificationOutput, 0, size); // Verify result for Random access for(int i = 0; i < (int)length; i++) { cl_uint index = i % GROUP_SIZE; //cl_uint index = 0; for(int j = 0; j < NUM_READS; j++) { for(int k =0 ; k<vectorSize ;k++) { verificationOutput[i * vectorSize + k] += input[index * vectorSize + k]; } index = (cl_uint)(verificationOutput[i * vectorSize + 0]) % 320; } } if(!memcmp(output, verificationOutput, size)) { std::cout << "Passed!\n" << std::endl; return SDK_SUCCESS; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } } return SDK_SUCCESS; }
int main(int ac, char **av) { int fd; struct stat sbuf; void *buf; int parallel = 1; int warmup = 0; int repetitions = TRIES; size_t nbytes; state_t state; int c; char *usage = "[-C] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] <size> open2close|mmap_only <filename>"; state.clone = 0; while (( c = getopt(ac, av, "P:W:N:C")) != EOF) { switch(c) { case 'P': parallel = atoi(optarg); if (parallel <= 0) lmbench_usage(ac, av, usage); break; case 'W': warmup = atoi(optarg); break; case 'N': repetitions = atoi(optarg); break; case 'C': state.clone = 1; break; default: lmbench_usage(ac, av, usage); break; } } /* should have three arguments left (bytes type filename) */ if (optind + 3 != ac) { lmbench_usage(ac, av, usage); } nbytes = state.nbytes = bytes(av[optind]); strcpy(state.filename,av[optind+2]); CHK(stat(state.filename, &sbuf)); if ((S_ISREG(sbuf.st_mode) && nbytes > sbuf.st_size) || (nbytes < MINSZ)) { fprintf(stderr,"<size> out of range!\n"); exit(1); } if (!strcmp("open2close", av[optind+1])) { benchmp(initialize, time_with_open, cleanup, 0, parallel, warmup, repetitions, &state); } else if (!strcmp("mmap_only", av[optind+1])) { benchmp(init_open, time_no_open, cleanup, 0, parallel, warmup, repetitions, &state); } else { lmbench_usage(ac, av, usage); } bandwidth(nbytes, get_n() * parallel, 0); return (0); }
int LDSBandwidth::runCLKernels(void) { int status; if(vec3 == true) { printf("\nAccessType\t: single\nVectorElements\t: %d\n", 3); } else { printf("\nAccessType\t: single\nVectorElements\t: %d\n", vectorSize); } printf("Bandwidth\t"); // Measure bandwidth of single reads from LDS status = bandwidth(kernel[0]); if(status != SDK_SUCCESS) { return SDK_FAILURE; } if(sampleArgs->verify) { // Check group size against kernelWorkGroupSize status = clGetKernelWorkGroupInfo(kernel[2], devices[sampleArgs->deviceId], CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &kernelWorkGroupSize, 0); CHECK_OPENCL_ERROR(status, "clGetKernelWorkGroupInfo failed."); size_t globalThreads = length; size_t localThreads = kernelWorkGroupSize; size_t size = (NUM_READS + localThreads) * vectorSize * sizeof(cl_float); // Local memory int status = clSetKernelArg(kernel[2], 0, size, 0); CHECK_OPENCL_ERROR(status, "clSetKernelArg failed.(local memory)"); // Output buffer status = clSetKernelArg(kernel[2], 1, sizeof(cl_mem), (void *)&outputBuffer); CHECK_OPENCL_ERROR(status, "clSetKernelArg failed.(outputBuffer)"); // Enqueue a kernel run call status = clEnqueueNDRangeKernel(commandQueue, kernel[2], 1, NULL, &globalThreads, &localThreads, 0, NULL, 0); CHECK_OPENCL_ERROR(status, "clEnqueueNDRangeKernel failed."); // wait for the kernel call to finish execution status = clFinish(commandQueue); CHECK_OPENCL_ERROR(status, "clFinish failed."); // Read back data from device to host cl_float* vBuffer = (cl_float*)malloc(vectorSize * sizeof(cl_float) * length); status = clEnqueueReadBuffer(commandQueue, outputBuffer, 1, 0, vectorSize * sizeof(cl_float) * length, vBuffer, 0, 0, 0); CHECK_OPENCL_ERROR(status, "clEnqueueReadBuffer failed."); int VecElements = (vec3 == true) ? 3 : vectorSize; int flag = 0; for(int i = 0; i < (int)length; i++) { for(int k = 0; k < VecElements; k++) { if(vBuffer[i * vectorSize + k] > 1e-5) { flag = 1; break; } } } if(!flag) { std::cout << "Passed!\n" << std::endl; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } free(vBuffer); } if(vec3 == true) { printf("\nAccessType\t: linear\nVectorElements\t: %d\n", 3); } else { printf("\nAccessType\t: linear\nVectorElements\t: %d\n", vectorSize); } printf("Bandwidth\t"); // Measure bandwidth of linear reads from LDS status = bandwidth(kernel[1]); if(status != SDK_SUCCESS) { return SDK_FAILURE; } if(sampleArgs->verify) { // Check group size against kernelWorkGroupSize status = clGetKernelWorkGroupInfo(kernel[3], devices[sampleArgs->deviceId], CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &kernelWorkGroupSize, 0); CHECK_OPENCL_ERROR(status, "clGetKernelWorkGroupInfo failed."); size_t globalThreads = length; size_t localThreads = kernelWorkGroupSize; size_t size = (NUM_READS + localThreads) * vectorSize * sizeof(cl_float); // Local memory int status = clSetKernelArg(kernel[3], 0, size, 0); CHECK_OPENCL_ERROR(status, "clSetKernelArg failed.(local memory)"); // Output buffer status = clSetKernelArg(kernel[3], 1, sizeof(cl_mem), (void *)&outputBuffer); CHECK_OPENCL_ERROR(status, "clSetKernelArg failed.(outputBuffer)"); // Enqueue a kernel run call status = clEnqueueNDRangeKernel(commandQueue, kernel[3], 1, NULL, &globalThreads, &localThreads, 0, NULL, 0); CHECK_OPENCL_ERROR(status, "clEnqueueNDRangeKernel failed."); // wait for the kernel call to finish execution status = clFinish(commandQueue); CHECK_OPENCL_ERROR(status, "clFinish failed."); // Read back data from device to host cl_float* vBuffer = (cl_float*)malloc(vectorSize * sizeof(cl_float) * length); status = clEnqueueReadBuffer(commandQueue, outputBuffer, 1, 0, vectorSize * sizeof(cl_float) * length, vBuffer, 0, 0, 0); CHECK_OPENCL_ERROR(status, "clEnqueueReadBuffer failed."); int flag = 0; for(int i = 0; i < (int)length; i++) { for(int k = 0; k < vectorSize; k++) { if(vBuffer[i * vectorSize + k] > 1e-5) { flag = 1; break; } } } if(!flag) { std::cout << "Passed!\n" << std::endl; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } FREE(vBuffer); } if(vec3 == true) { printf("\nAccessType\t: linear write\nVectorElements\t: %d\n", 3); } else { printf("\nAccessType\t: linear write\nVectorElements\t: %d\n", vectorSize); } printf("Bandwidth\t"); status = bandwidth(kernel[4]); if(status != SDK_SUCCESS) { return SDK_FAILURE; } if(sampleArgs->verify) { // Check group size against kernelWorkGroupSize status = clGetKernelWorkGroupInfo(kernel[5], devices[sampleArgs->deviceId], CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &kernelWorkGroupSize, 0); CHECK_OPENCL_ERROR(status, "clGetKernelWorkGroupInfo failed."); size_t globalThreads = length; size_t localThreads = kernelWorkGroupSize; size_t size = (NUM_READS + localThreads) * vectorSize * sizeof(cl_float); // Local memory int status = clSetKernelArg(kernel[5], 0, size, 0); CHECK_OPENCL_ERROR(status, "clSetKernelArg failed.(local memory)"); // Output buffer status = clSetKernelArg(kernel[5], 1, sizeof(cl_mem), (void *)&outputBuffer); CHECK_OPENCL_ERROR(status, "clSetKernelArg failed.(outputBuffer)"); // Enqueue a kernel run call status = clEnqueueNDRangeKernel(commandQueue, kernel[5], 1, NULL, &globalThreads, &localThreads, 0, NULL, 0); CHECK_OPENCL_ERROR(status, "clEnqueueNDRangeKernel failed."); // wait for the kernel call to finish execution status = clFinish(commandQueue); CHECK_OPENCL_ERROR(status, "clFinish failed."); // Read back data from device to host cl_float* vBuffer = (cl_float*)malloc(vectorSize * sizeof(cl_float) * length); status = clEnqueueReadBuffer(commandQueue, outputBuffer, 1, 0, vectorSize * sizeof(cl_float) * length, vBuffer, 0, 0, 0); CHECK_OPENCL_ERROR(status, "clEnqueueReadBuffer failed."); int VecElements = (vec3 == true) ? 3 : vectorSize; int flag = 0; for(int i = 0; i < (int)length; i++) { for(int k = 0; k < VecElements; k++) { if(vBuffer[i * vectorSize + k] > 1e-5) { flag = 1; break; } } } if(!flag) { std::cout << "Passed!\n" << std::endl; } else { std::cout << "Failed!\n" << std::endl; return SDK_FAILURE; } free(vBuffer); } return SDK_SUCCESS; }
virtual std::ostream& dump_header(std::ostream& os) const { os << "# Frequency = " << boost::format("%12.3f") % fReference() << " [Hz]\n" << "# Bandwidth = " << boost::format("%9.3f") % bandwidth() << " [Hz]\n"; Base::dump_header(os); return os << "strength_dBm averageStrength_dBm strengthRMS_dBm "; }