Exemple #1
0
void Hdd::configAccepted()
{
    KConfigGroup cg = config();
    KConfigGroup cgGlobal = globalConfig();
    QStandardItem *parentItem = m_hddModel.invisibleRootItem();

    clear();

    for (int i = 0; i < parentItem->rowCount(); ++i) {
        QStandardItem *item = parentItem->child(i, 0);
        if (item) {
            QStandardItem *child = parentItem->child(i, 1);
            if (child->text() != child->data().toString()) {
                cgGlobal.writeEntry(item->data().toString(), child->text());
            }
            if (item->checkState() == Qt::Checked) {
                appendSource(item->data().toString());
            }
        }
    }
    cg.writeEntry("uuids", sources());

    uint interval = ui.intervalSpinBox->value();
    cg.writeEntry("interval", interval);

    emit configNeedsSaving();
}
Exemple #2
0
int OpenCL::load_kernels(std::vector<std::string> source_paths) {
	std::vector<std::string> sources(source_paths.size());
	const char* source_ptr[source_paths.size()];
	for (int i = 0; i < source_paths.size(); i++) {
		std::ifstream file(source_paths[i]);
		std::stringstream buffer;

		buffer << file.rdbuf();
		sources[i] = buffer.str();
		source_ptr[i] = sources[i].c_str();

		std::cout << "--- source code loaded for file " << source_paths[i] << " ---" << std::endl;
	}

	// Create the program from source and build it.
	cl_program program;
	SAFE_REF(program = clCreateProgramWithSource(context, source_paths.size(), source_ptr, NULL, &err));
	SAFE_BUILD(clBuildProgram(program, 0, NULL, "-I../src/util", NULL, NULL));

	cl_kernel kernel_pr, kernel_tr;
	SAFE_REF(kernel_pr = clCreateKernel(program, "produceray", &err));
	SAFE_REF(kernel_tr = clCreateKernel(program, "traceray", &err));
	kernels.push_back(kernel_pr);
	kernels.push_back(kernel_tr);

	return CL_SUCCESS;
}
GEODESIC_DLL_IMPORT void propagate(long algorithm_id,
									double* source_points,	
									long num_sources,
									double* stop_points,	
									long num_stop_points,
									double max_propagation_distance)
{
	std::vector<geodesic::SurfacePoint> sources(num_sources);

	geodesic::Mesh* mesh = algorithms[algorithm_id]->mesh();
	for(std::size_t i=0; i<num_sources; ++i)
	{
		geodesic::fill_surface_point_structure(&sources[i], 
												source_points + 5*i, 
												mesh);
	}

	std::vector<geodesic::SurfacePoint> stop(num_stop_points);
	for(std::size_t i=0; i<num_stop_points; ++i)
	{
		geodesic::fill_surface_point_structure(&stop[i], 
												stop_points + 5*i, 
												mesh);
	}

	algorithms[algorithm_id]->propagate(sources, 
										max_propagation_distance,
										&stop);
}
JNIEXPORT jboolean JNICALL Java_com_example_LiveFeatureActivity_compileKernels(JNIEnv *env, jclass clazz)
{
    // Find OCL devices and compile kernels
    cl_int err = CL_SUCCESS;
    try {
        std::vector<cl::Platform> platforms;
        cl::Platform::get(&platforms);
        if (platforms.size() == 0) {
            return false;
        }
        cl_context_properties properties[] =
        { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0};
        gContext = cl::Context(CL_DEVICE_TYPE_GPU, properties);
        std::vector<cl::Device> devices = gContext.getInfo<CL_CONTEXT_DEVICES>();
        gQueue = cl::CommandQueue(gContext, devices[0], 0, &err);
        int src_length = 0;
		const char* src  = file_contents("/data/data/com.example/app_execdir/kernels.cl",&src_length);
        cl::Program::Sources sources(1,std::make_pair(src, src_length) );
        cl::Program program(gContext, sources);
        program.build(devices,NULL,cb);
        while(program.getBuildInfo<CL_PROGRAM_BUILD_STATUS>(devices[0]) != CL_BUILD_SUCCESS);
        gNV21Kernel = cl::Kernel(program, "nv21torgba", &err);
        gLaplacianK = cl::Kernel(program, "laplacian", &err);
        gNegative = cl::Kernel(program, "negative", &err);
        return true;
    }
    catch (cl::Error e) {
        if( !throwJavaException(env,"decode",e.what(),e.err()) )
            LOGI("@decode: %s \n",e.what());
        return false;
    }
}
Exemple #5
0
int main() {
  typedef TempKernel kernel_type;
  typedef kernel_type::source_type source_type;
  typedef kernel_type::charge_type charge_type;
  typedef kernel_type::target_type target_type;
  typedef kernel_type::result_type result_type;

  kernel_type K;

  // init source
  std::vector<source_type> sources(2);

  // init charge
  std::vector<charge_type> charges(sources.size());

  // init target
  std::vector<target_type> targets(2);

  // init results vectors for exact
  std::vector<result_type> exact(targets.size());

  // test direct
  fmmtl::direct(K, sources, charges, targets, exact);
  std::cout << exact[0] << "\n";
  fmmtl::direct(K, sources, charges, exact);
  std::cout << exact[0] << "\n";
}
Exemple #6
0
std::vector<debug_log> debug_logs(GLuint count)
{
  auto max_message_size = 0;
  glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &max_message_size);

  std::vector<GLenum>  sources      (count);
  std::vector<GLenum>  types        (count);
  std::vector<GLuint>  ids          (count);
  std::vector<GLenum>  severities   (count);
  std::vector<GLsizei> message_sizes(count);
  std::vector<GLchar>  message_data (count * max_message_size);
  auto real_count = glGetDebugMessageLog(count, static_cast<GLsizei>(message_data.size()), &sources[0], &types[0], &ids[0], &severities[0], &message_sizes[0], &message_data[0]);
  sources      .resize(real_count);
  types        .resize(real_count);
  ids          .resize(real_count);
  severities   .resize(real_count);
  message_sizes.resize(real_count);

  std::vector<std::string> messages(real_count);
  auto current_message = message_data.begin();
  for (size_t i = 0; i < message_sizes.size(); ++i)
  {
    messages[i] = std::string(current_message, current_message + message_sizes[i] - 1);
    current_message = current_message + message_sizes[i];
  }

  std::vector<debug_log> debug_logs(real_count);
  for (unsigned i = 0; i < real_count; i++)
    debug_logs[i] = debug_log{sources[i], types[i], ids[i], severities[i], messages[i], nullptr};
  return debug_logs;
}
int hybrid_fmm_stokes_solver(int ac, char **av)
{
    srand(0);
    bool dump_tree_data = false;
    vtkSmartPointer<vtkPolyData>   poly_data = vtkSmartPointer<vtkPolyData>::New();
    vtkSmartPointer<vtkPoints>     points = vtkSmartPointer<vtkPoints>::New();
    vtkSmartPointer<vtkFloatArray> data_points = vtkSmartPointer<vtkFloatArray>::New();
    vtkSmartPointer<vtkCellArray>  cells = vtkSmartPointer<vtkCellArray>::New();
    typedef float value_type;
    size_t num_sources = 1 << 8;
    size_t num_targets = 1 << 8;
    size_t size_sources = 3 * num_sources;
    size_t size_targets = 3 * num_targets;
    std::vector<value_type> sources(size_sources), targets(size_targets), velocities(size_targets), forces(size_sources);
    value_type delta = .0001;
    HybridFmmStokesSolver<value_type> fmm(num_sources);
    std::generate(sources.begin(), sources.end(), random_generator<value_type>());
    std::generate(targets.begin(), targets.end(), random_generator<value_type>());
    std::generate(forces.begin(), forces.end(), random_generator<value_type>());
    std::cout << "sources = ["; std::copy(sources.begin(), sources.end(), std::ostream_iterator<value_type>(std::cout, " ")); std::cout << "];" << std::endl;
    std::cout << "targets = ["; std::copy(targets.begin(), targets.end(), std::ostream_iterator<value_type>(std::cout, " ")); std::cout << "];" << std::endl;
    std::cout << "forces = ["; std::copy(forces.begin(), forces.end(), std::ostream_iterator<value_type>(std::cout, " ")); std::cout << "];" << std::endl;
    fmm.setDelta(delta);
    fmm(0, &sources[0], &velocities[0], &forces[0]);
    std::fill(velocities.begin(), velocities.end(), 0.0);
    fmm.allPairs();
    if (dump_tree_data)
    {
        IO::VtkWriter<vtkXMLPolyDataWriter> writer("data/points");
        data_points->SetArray(&sources[0], sources.size(), 1);
        data_points->SetNumberOfComponents(3);
        data_points->SetName("positions");
        points->SetData(data_points);
        poly_data->SetPoints(points);
        for (vtkIdType i = 0; i < num_sources; ++i)
            cells->InsertNextCell(VTK_VERTEX, &i);
        poly_data->SetVerts(cells);
        writer.write(poly_data, 0, false);
        write_vtk_octree();
    }
#ifdef USE_QT_GUI
    QApplication app(ac, av);

    if (!QGLFormat::hasOpenGL())
    {
        std::cerr << "This system has no OpenGL support" << std::endl;
        return 1;
    }
    QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);
    OctreeRenderer tree_renderer;
    tree_renderer.init(octree);
    tree_renderer.setWindowTitle(QObject::tr("Quad Tree"));
    tree_renderer.setMinimumSize(200, 200);
    tree_renderer.resize(800, 600);
    tree_renderer.show();
    return app.exec();
#else
    return 0;
#endif
}
void CDownloadQueue::AddSearchToDownload(CSearchFile* toadd, uint8 category)
{
	if ( IsFileExisting(toadd->GetFileHash()) ) {
		return;
	}

	if (toadd->GetFileSize() > OLD_MAX_FILE_SIZE) {
		if (!PlatformSpecific::CanFSHandleLargeFiles(thePrefs::GetTempDir())) {
			AddLogLineC(_("Filesystem for Temp directory cannot handle large files."));
			return;
		} else if (!PlatformSpecific::CanFSHandleLargeFiles(theApp->glob_prefs->GetCatPath(category))) {
			AddLogLineC(_("Filesystem for Incoming directory cannot handle large files."));
			return;
		}
	}

	CPartFile* newfile = NULL;
	try {
		newfile = new CPartFile(toadd);
	} catch (const CInvalidPacket& WXUNUSED(e)) {
		AddDebugLogLineC(logDownloadQueue, wxT("Search-result contained invalid tags, could not add"));
	}
	
	if ( newfile && newfile->GetStatus() != PS_ERROR ) {
		AddDownload( newfile, thePrefs::AddNewFilesPaused(), category );
		// Add any possible sources
		if (toadd->GetClientID() && toadd->GetClientPort()) {
			CMemFile sources(1+4+2);
			sources.WriteUInt8(1);
			sources.WriteUInt32(toadd->GetClientID());
			sources.WriteUInt16(toadd->GetClientPort());
			sources.Reset();
			newfile->AddSources(sources, toadd->GetClientServerIP(), toadd->GetClientServerPort(), SF_SEARCH_RESULT, false);
		}
		for (std::list<CSearchFile::ClientStruct>::const_iterator it = toadd->GetClients().begin(); it != toadd->GetClients().end(); ++it) {
			CMemFile sources(1+4+2);
			sources.WriteUInt8(1);
			sources.WriteUInt32(it->m_ip);
			sources.WriteUInt16(it->m_port);
			sources.Reset();
			newfile->AddSources(sources, it->m_serverIP, it->m_serverPort, SF_SEARCH_RESULT, false);
		}
	} else {
		delete newfile;
	}
}
Exemple #9
0
void Netctl::initSources()
{
    if (debug) qDebug() << PDEBUG;

    QStringList sourcesList = sources();
    for (int i=0; i<sourcesList.count(); i++)
        setData(sourcesList[i], QString("value"), QString("N\\A"));
}
void LogMessages(Settings settings)
{
	LogSources sources(true);
	sources.AddDBWinReader(false);
	if (HasGlobalDBWinReaderRights())
		sources.AddDBWinReader(true);

	sources.SetAutoNewLine(settings.autonewline);

	std::ofstream fs;

	if (!settings.filename.empty())
	{
		OpenLogFile(fs, WStr(settings.filename));
		fs.flush();
	}

	auto guard = make_guard([&fs, &settings]()
	{
		if (!settings.filename.empty())
		{
			fs.flush();
			fs.close();
			std::cout << "Log file closed.\n";
		}
	});

	std::string separator = settings.tabs ? "\t" : " ";
	while (!g_quit)
	{
		auto lines = sources.GetLines();
		int linenumber = 0;
		for (auto it = lines.begin(); it != lines.end(); ++it)
		{
			if (settings.console)
			{
				if (settings.linenumber)
				{
					++linenumber;
					std::cout << std::setw(5) << std::setfill('0') << linenumber << std::setfill(' ') << separator;
				}
				OutputDetails(settings, *it);
				std::cout << separator << it->message.c_str() << "\n";
			}
			if (!settings.filename.empty())
			{
				WriteLogFileMessage(fs, it->time, it->systemTime, it->pid, it->processName, it->message);
			}
		}
		if (settings.flush)
		{
			std::cout.flush();
			fs.flush();
		}
		Sleep(250);
	}
	std::cout.flush();
}
Exemple #11
0
 std::vector<T> getModelObjectSources() const {
   std::vector<T> result;
   std::vector<WorkspaceObject> wos = sources();
   for (const WorkspaceObject& wo : wos) {
     boost::optional<T> oSource = wo.optionalCast<T>();
     if (oSource) { result.push_back(*oSource); }
   }
   return result;
 }
   Signal* NonlinearMatrix::getSource(int number) const
   {
      for(auto signal : sources())
      {
         if(signal->number() == number)
            return signal;
      }

      return nullptr;
   }
/*
 * Processes a frame
 */
void LinemodInterface::process(const cv::Mat &color, const cv::Mat &depth, std::vector<Result> &results, const float minResponse,
                               const std::vector<std::string> &classes, const cv::Mat &mask)
{
  cv::Mat _depth;

  switch(depth.type())
  {
  case CV_32F:
    depth.convertTo(_depth, CV_16U, 1000.0);
    break;
  case CV_16U:
    _depth = depth;
    break;
  default:
    return;
  }

  std::vector<cv::Mat>
  sources(2),
          masks;
  sources[0] = color;
  sources[1] = _depth;

  if(!mask.empty())
  {
    masks.resize(2);
    masks[0] = mask.clone();
    masks[1] = mask.clone();
  }

  matches.clear();
  detector->match(sources, minResponse, matches, classes, cv::noArray(), masks);

  std::map<std::string, int> best;
  std::map<std::string, int>::iterator it;
  Result result;
  results.clear();

  for(int i = 0; i < (int)matches.size(); ++i)
  {
    cv::linemod::Match &match = matches[i];

    setResult(match, result);

    it = best.find(result.name);
    if(it == best.end())
    {
      best[result.name] = i;

      setResult(match, result);
      results.push_back(result);
    }
  }
}
Exemple #14
0
   // ----------------------------------------------------------------------
   void
   CreateEdgesTagTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);
#ifndef HAVE_BOOST_REGEX
      throw std::runtime_error("no boost::regex support compiled in");
#else
      boost::regex sources(sc.environment().required_string_param("source_regex"));
      boost::regex targets(sc.environment().required_string_param("target_regex"));
      std::string taglabel = sc.environment().required_string_param("tag");

      std::string pref = sc.environment().
         optional_string_param("prefix",DrawableEdgeDefault::PREFIX);
      std::string node_prefix =
         sc.environment().
         optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);
      GroupElement* grp = group(sc);

      for( shawn::World::const_node_iterator
              it    = visualization().world().begin_nodes(),
              endit = visualization().world().end_nodes();
           it != endit; ++it )
      {
         
         if( boost::regex_search(get_stringtag(&*it,taglabel)->value(),sources))
            {
               for( shawn::Node::const_adjacency_iterator
                       ait    = it->begin_adjacent_nodes(),
                       endait = it->end_adjacent_nodes();
                    ait != endait; ++ait )
                  if( *it != *ait )
                     if( boost::regex_search(get_stringtag(&*ait,taglabel)->value(),targets) )
                        if( (ait->label() > it->label()) ||
                            (!boost::regex_search(get_stringtag(&*it,taglabel)->value(),targets)) ||
                            (!boost::regex_search(get_stringtag(&*ait,taglabel)->value(),sources)) )
                           {
                              const DrawableNode* dsrc =
                                 drawable_node(*it,node_prefix);
                              const DrawableNode* dtgt =
                                 drawable_node(*ait,node_prefix);
                              DrawableEdgeDefault* ded =
                                 new DrawableEdgeDefault(*it,*ait,*dsrc,*dtgt,pref);
                              ded->init();
                              visualization_w().add_element(ded);
                              if( grp != NULL )
                                 grp->add_element(*ded);
                           }
            }
      }
#endif
   }
Exemple #15
0
/*!
  \reimp
  */
void QDependentEventsContext::setVisibleSources(const QSet<QPimSource> &set)
{
    QSet<int> show;
    QSet<int> hide;
    QSet<QPimSource> list = sources();
    foreach (QPimSource s, list) {
        int context = QPimSqlIO::sourceContext(s);
        if (set.contains(s)) {
            show.insert(context);
        } else {
            hide.insert(context);
        }
    }
Exemple #16
0
void nix::file::BlockFS::createSubFolders(const std::shared_ptr<base::IFile> &file) {
    bfs::path data_arrays("data_arrays");
    bfs::path tags("tags");
    bfs::path multi_tags("multi_tags");
    bfs::path sources("sources");
    bfs::path p(location());
    bfs::path groups("groups");

    data_array_dir = Directory(p / data_arrays, file->fileMode());
    tag_dir = Directory(p / tags, file->fileMode());
    multi_tag_dir = Directory(p / multi_tags, file->fileMode());
    source_dir = Directory(p / sources, file->fileMode());
    group_dir = Directory(p / groups, file->fileMode());
}
void CDownloadQueue::OnHostnameResolved(uint32 ip)
{
	wxMutexLocker lock( m_mutex );

	wxASSERT( m_toresolve.size() );
	
	Hostname_Entry resolved = m_toresolve.front();
	m_toresolve.pop_front();

	if ( ip ) {
		CPartFile* file = GetFileByID( resolved.fileid );
		if ( file ) {
			CMemFile sources(1+4+2);
			sources.WriteUInt8(1); // No. Sources
			sources.WriteUInt32(ip);
			sources.WriteUInt16(resolved.port);
			sources.WriteUInt8(resolved.cryptoptions);
			if (resolved.cryptoptions & 0x80) {
				wxASSERT(!resolved.hash.IsEmpty());
				CMD4Hash sourcehash;
				sourcehash.Decode(resolved.hash);
				sources.WriteHash(sourcehash);
			}
			sources.Seek(0,wxFromStart);
			
			file->AddSources(sources, 0, 0, SF_LINK, true);
		}
	}
	
	while (m_toresolve.size()) {
		Hostname_Entry entry = m_toresolve.front();

		// Check if it is a simple dot address
		uint32 tmpIP = StringIPtoUint32(entry.strHostname);

		if (tmpIP) {
			OnHostnameResolved(tmpIP);
		} else {
			CAsyncDNS* dns = new CAsyncDNS(entry.strHostname, DNS_SOURCE, theApp);

			if ((dns->Create() != wxTHREAD_NO_ERROR) || (dns->Run() != wxTHREAD_NO_ERROR)) {
				dns->Delete();
				m_toresolve.pop_front();
			} else {
				break;
			}
		}
	}
}
Exemple #18
0
CommPtr Comm::graph_adjacent(Read<I32> srcs, Read<I32> dsts) const {
#ifdef OMEGA_H_USE_MPI
  MPI_Comm impl2;
  HostRead<I32> sources(srcs);
  HostRead<I32> destinations(dsts);
  int reorder = 0;
  CALL(MPI_Dist_graph_create_adjacent(impl_, sources.size(), sources.data(),
      OMEGA_H_MPI_UNWEIGHTED, destinations.size(), destinations.data(),
      OMEGA_H_MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &impl2));
  return CommPtr(new Comm(impl2));
#else
  CHECK(srcs == dsts);
  return CommPtr(new Comm(true, dsts.size() == 1));
#endif
}
Exemple #19
0
void source( char *file ) {
    static char findpath[ _MAX_PATH ];
    static char findname[ _MAX_PATH ];

    fn_split( file );
/*
    _splitpath( file, disk, path, name, ext );
*/
    if ( strchr( file, '?' ) || strchr( file, '*' ) ) {  /* Check for '*' and '?' */
        _makepath( findpath, fn_drive(), fn_dir(), NULL, NULL );
        _makepath( findname, NULL, NULL, fn_name(), fn_ext() );
        sources( findpath, findname );
    }
    else
        one_source( file );
}
Exemple #20
0
cl::Program
ClCmdQueue::createProgram(const std::string& source) throw(cl::Error) {
    // Create the program from source
    cl::Program::Sources sources(1, std::make_pair(source.c_str(), 0));
    cl::Program program(context, sources);
    // Build Open CL program for a given device
    try {
        program.build({ device });
    } catch (cl::Error error) {
        std::cout << "Build log:" << std::endl
                  << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)
                  << std::endl;
        throw error;
    }
    return program;
}
Exemple #21
0
void test_kernel(const Kernel& K) {
  typedef typename Kernel::source_type source_type;
  typedef typename Kernel::charge_type charge_type;
  typedef typename Kernel::target_type target_type;
  typedef typename Kernel::result_type result_type;

  std::vector<source_type> sources(1);
  std::vector<charge_type> charges(1);
  std::vector<target_type> targets(1);
  std::vector<result_type> results(1);

  Direct::matvec(K, sources, charges, targets, results);

  std::cout << results[0] << std::endl;
  std::cout << KernelTraits<Kernel>() << std::endl;
  std::cout << typeid(Kernel).name() << " OK." << std::endl;
}
Exemple #22
0
Comm::Comm(MPI_Comm impl) : impl_(impl) {
  int topo_type;
  CALL(MPI_Topo_test(impl, &topo_type));
  if (topo_type == MPI_DIST_GRAPH) {
    int nin, nout, is_weighted;
    CALL(MPI_Dist_graph_neighbors_count(impl, &nin, &nout, &is_weighted));
    HostWrite<I32> sources(nin);
    HostWrite<I32> destinations(nout);
    CALL(MPI_Dist_graph_neighbors(impl, nin, sources.data(),
        OMEGA_H_MPI_UNWEIGHTED, nout, destinations.data(),
        OMEGA_H_MPI_UNWEIGHTED));
    srcs_ = sources.write();
    dsts_ = destinations.write();
    host_srcs_ = HostRead<I32>(srcs_);
    host_dsts_ = HostRead<I32>(dsts_);
  }
}
Exemple #23
0
// -------------------------------------------------------------------------
cl::Program MorphOpenCL::createProgram(const char* progFile, const char* options)
{
	if(error) return cl::Program();

	QFile file(progFile);
	if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		clError("Can't read " + 
			QString(progFile) + 
			" file!", -1);
		return cl::Program();
	}

	QTextStream in(&file);
	QString contents = in.readAll();

	QByteArray w = contents.toLocal8Bit();
	const char* src = w.data();
	size_t len = contents.length();

	cl_int err;
	cl::Program::Sources sources(1, std::make_pair(src, len));
	cl::Program program = cl::Program(context, sources, &err);
	clError("Failed to create compute program from" + QString(progFile), err);
	if(error) return cl::Program();

	std::vector<cl::Device> devs(1);
	devs[0] = (dev);

	printf("Building %s program...", progFile);
	err = program.build(devs, options);
	QString log(QString::fromStdString(
		program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(dev)));
	if(err != CL_SUCCESS)
		clError(log, err);
	if(!error) printf("[OK]\n");

	if(log.size() > 0)
	{
		std::string slog = log.toStdString();
		printf("log: %s\n", slog.c_str());
	}
	return program;
}
bool NetworkManagementEngine::sourceRequestEvent(const QString &name)
{
    kDebug() << "Source requested:" << name << sources();
    setData(name, DataEngine::Data());
    //setData("networkStatus", "isConnected", true);
    //scheduleSourcesUpdated();

    if (name == "connections") {
        connect(d->activatables, SIGNAL(activatableAdded(RemoteActivatable*)),
                SLOT(activatableAdded(RemoteActivatable*)));
        connect(d->activatables, SIGNAL(activatableRemoved(RemoteActivatable*)),
                SLOT(activatableRemoved(RemoteActivatable*)));

        connect(d->activatables, SIGNAL(appeared()), SLOT(listAppeared()));
        connect(d->activatables, SIGNAL(disappeared()), SLOT(listDisappeared()));
        kDebug() << "connected...";
        listAppeared();
        return true;
    }
cl::Kernel
getKernel(std::vector<cl::Device>& deviceList, cl::Context& context,
          const std::string& sourceCode, const std::string& entryFunc) {
    // Create the program from source for given device    
    cl::Program::Sources sources(1, std::make_pair(sourceCode.c_str(), 0));
    cl::Program program(context, sources);
    // Build Open CL program for a given device
    try {
        program.build(deviceList);
    } catch (cl::Error error) {
        std::cout << "Build log:" << std::endl
                  << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(deviceList[0])
                  << std::endl;
        throw error;
    }
    // Create and return a kernel
    cl::Kernel kernel(program, entryFunc.c_str());
    return kernel;
}
Exemple #26
0
cl::Kernel * compile(const std::string & name, const std::string & code, const std::string & flags, cl::Context & clContext, cl::Device & clDevice) {
  cl::Program * program = 0;
  cl::Kernel * kernel = 0;
  try {
    cl::Program::Sources sources(1, std::make_pair(code.c_str(), code.length()));
    program = new cl::Program(clContext, sources, NULL);
    program->build(std::vector<cl::Device>(1, clDevice), flags.c_str(), NULL, NULL);
  } catch ( cl::Error & err ) {
    throw isa::OpenCL::OpenCLError("ERROR: OpenCL build error \"" + program->getBuildInfo<CL_PROGRAM_BUILD_LOG>(clDevice) + "\"");
  }
  try {
    kernel = new cl::Kernel(*program, name.c_str(), NULL);
    delete program;
  } catch ( cl::Error &err ) {
    throw isa::OpenCL::OpenCLError("ERROR: OpenCL kernel error \"" + isa::utils::toString<cl_int>(err.err()) + "\"");
  }

  return kernel;
}
cl::Program OCLSample::compileSource(const std::string& filename) {
  cl_int result;

  std::ifstream kernelStream(filename.c_str());
  std::string source(std::istreambuf_iterator<char>(kernelStream),
                     (std::istreambuf_iterator<char>()));
  kernelStream.close();

  cl::Program::Sources sources(1, std::make_pair(source.c_str(),
                                                 source.size()));
  cl::Program program(context_, sources, &result);
  assert(result == CL_SUCCESS && "Failed to load program source");
  std::vector<cl::Device> devices;
  devices.push_back(device_);
  result = program.build(devices);
  if(result != CL_SUCCESS) {
    std::cerr << "Source compilation failed.\n";
    std::cerr << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(device_);
    assert(false && "Unable to continue");
  }
  return program;
}
Exemple #28
0
int fmm_stokes_solver(int ,char **)
{
    srand(0);
    typedef double value_type;
    size_t num_sources = 100;
    size_t num_targets = 100;
    size_t size_sources = 3*num_sources;
    size_t size_targets = 3*num_targets;
    std::vector<value_type> sources(size_sources), targets(size_targets), velocities(size_targets), forces(size_sources);
    value_type delta = .01;
    FmmStokesSolver<double,25,6> solver(num_sources);
    solver.setDelta(delta);

    std::generate(sources.begin(),sources.end(),random_generator<value_type>());
    std::generate(targets.begin(),targets.end(),random_generator<value_type>());
    std::generate(velocities.begin(),velocities.end(),random_generator<value_type>());
    std::generate(forces.begin(),forces.end(),random_generator<value_type>());

    solver(0,&targets[0],&velocities[0],&sources[0],&forces[0]);
    
    return 0;
}
Exemple #29
0
void Hdd::createConfigurationInterface(KConfigDialog *parent)
{
    QWidget *widget = new QWidget();
    ui.setupUi(widget);
    m_hddModel.clear();
    m_hddModel.setHorizontalHeaderLabels(QStringList() << i18n("Mount Point")
                                                       << i18n("Name"));
    QStandardItem *parentItem = m_hddModel.invisibleRootItem();
    Plasma::DataEngine::Data data;
    QString predicateString("IS StorageVolume");

    foreach (const QString& uuid, engine()->query(predicateString)[predicateString].toStringList()) {
        if (!isValidDevice(uuid, &data)) {
            continue;
        }
        QStandardItem *item1 = new QStandardItem(filePath(data));
        item1->setEditable(false);
        item1->setCheckable(true);
        item1->setData(uuid);
        if (sources().contains(uuid)) {
            item1->setCheckState(Qt::Checked);
        }
        QStandardItem *item2 = new QStandardItem(hddTitle(uuid, data));
        item2->setData(guessHddTitle(data));
        item2->setEditable(true);
        parentItem->appendRow(QList<QStandardItem *>() << item1 << item2);
    }
    ui.treeView->setModel(&m_hddModel);
    ui.treeView->resizeColumnToContents(0);
    ui.intervalSpinBox->setValue(interval() / 60 / 1000);
    ui.intervalSpinBox->setSuffix(ki18np(" minute", " minutes"));

    parent->addPage(widget, i18n("Partitions"), "drive-harddisk");
    connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
    connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
    connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
    connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
}
Exemple #30
0
    /// Creates a new program with \p files in \p context.
    ///
    /// \see_opencl_ref{clCreateProgramWithSource}
    static program create_with_source_file(const std::vector<std::string> &files,
                                           const context &context)
    {
        std::vector<std::string> sources(files.size());

        for(size_t i = 0; i < files.size(); ++i) {
            // open file stream
            std::ifstream stream(files[i].c_str());

            if(stream.fail()){
                BOOST_THROW_EXCEPTION(std::ios_base::failure("failed to create stream."));
            }

            // read source
            sources[i] = std::string(
                    (std::istreambuf_iterator<char>(stream)),
                    std::istreambuf_iterator<char>()
            );
        }

        // create program
        return create_with_source(sources, context);
    }