Giter Site home page Giter Site logo

Comments (2)

stephenswat avatar stephenswat commented on July 28, 2024 1

I would propose that we unify all algorithms in traccc under a standard interface, something like:

template<typename I, typename O>
class algorithm {
    void operator(const I & i, O & o);
};

Then, our algorithms can inherit from this class to provide us a consistent API:

namespace traccc::cuda {
    class component_connection : public algorithm<cell_container, cluster_container> {
        ...
    };
}

This would allow us to define compile-type types for composition, while allowing algorithm selection at runtime:

template<typename I, typename P, typename O>
class composition : public algorithm<I, O> {
    composition(algorithm<I, P> & a1, algorithm<P, O> & a2);
};

If we want to extend this concept, we can additionally define data location at compile time:

enum class storage {
    HOST,
    DEVICE,
    AGNOSTIC
};

template<typename I, typename O, storage Is=AGNOSTIC, storage Os=AGNOSTIC>
class algorithm {
    void operator(const I & i, O & o);
};

namespace traccc::cuda {
    class component_connection : public algorithm<cell_container, cluster_container, DEVICE, DEVICE> {
        ...
    };

    template<typename T>
    class host_to_device : public algorithm<T, T, HOST, DEVICE> {
        ...
    };
}

I think, in general, it is a good idea now to discuss how much we want to fix at compile time (giving us the security of having the type checker check our code for us), and how much we want to leave until runtime (so we can be more flexible at execution time).

from traccc.

beomki-yeo avatar beomki-yeo commented on July 28, 2024

I do like your suggestion.
Since even single algorithm may require various types of containers, can input and output type contain more than one container? For example:

template< typename I, typename O >  
class algorithm{    
public:
    virtual void operator()(const I& i, O& o){
        
    }
};

struct input_t{
    host_cell_container a;
    host_measurement_container b;
};

struct output_t{
    host_spacepoint_container b;
};

class test: public algorithm<input_t, output_t>{    
    
public:
    void operator()(const input_t& I, output_t& O) override {
        ...
    }
    
};

Of course the above code will force us to apply get_data() to every members of structure so it may not be a good solution.:p

from traccc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.