virtual void createUDPSockets(string _url, bool _testSocketWO) { ServiceAddress serviceAddress(_url, _testSocketWO? ServiceAddress::stUDPRO : ServiceAddress::stUDPWO); m_bfSocket = BFSocketUPtr(new BFSocket(serviceAddress)); bzero(&m_streamAddr, sizeof(m_streamAddr)); m_streamAddr.sin_family = AF_INET; m_streamAddr.sin_addr.s_addr = serviceAddress.hostAddress(); m_streamAddr.sin_port = htons(m_port); m_sockFd = socket(AF_INET, SOCK_DGRAM, 0); if(m_sockFd == -1) THROW_SOCKET_EXCEPTION("Could not create socket - " << strerror(errno)); if(!_testSocketWO) { if(bind(m_sockFd, (struct sockaddr *) &m_streamAddr, sizeof(m_streamAddr))) THROW_SOCKET_EXCEPTION("Could not bind UDP Socket - " << strerror(errno)); if(serviceAddress.isMulticast()) { struct ip_mreq mreq; zero_init(mreq); mreq.imr_multiaddr.s_addr = serviceAddress.hostAddress(); mreq.imr_interface.s_addr = htonl(INADDR_ANY); if (setsockopt(m_sockFd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) THROW_SOCKET_EXCEPTION("Could not add membership do socket - " << strerror(errno)); } } }
void Evaluator::eval(Variable_decl const* d) { // Create an uninitialized object and bind it // to the symbol. Keep a reference so we can // initialize it directly. Value v0 = get_value(d->type()); Value& v1 = stack.top().bind(d->name(), v0).second; // Handle initialization. // // FIXME: The initializer should hold a function // that can be evalated to perform the initialization // procedure. We shouldn't be doing this explicitly. Expr const* e = d->init(); // Perform default initialization. if (is<Default_init>(e)) zero_init(v1); // Perfor copy initialization. We should guarantee // that v1 and the evaluation of i produce values // of the same shape. else if (Copy_init const* i = as<Copy_init>(e)) v1 = eval(i->value()); else throw std::runtime_error("unhandled initializer"); }
KOKKOS_INLINE_FUNCTION void team_broadcast(const ValueType& value, const int& thread_id ) const { static_assert(std::is_trivially_default_constructible<ValueType>(), "Only trivial constructible types can be broadcasted"); tile_static ValueType local_value; zero_init(local_value); if (this->team_rank() == thread_id) { local_value = value; } this->team_barrier(); value = local_value; }
void operator()(Aggregate_value& v) { zero_init(v); };
void operator()(Reference_value& v) { zero_init(v); }
void operator()(Function_value& v) { zero_init(v); }
void operator()(Integer_value& v) { zero_init(v); };
// Recursively zero initialize the aggregate. void zero_init(Aggregate_value& v) { for (std::size_t i = 0; i < v.len; ++i) zero_init(v.data[i]); }
void Evaluator::eval_init(Default_init const* e, Value& v) { zero_init(v); }