/** * Calculates the coverage prediction for one transmitter, using the E/// model. * * params a structure holding configuration parameters which are * common to all transmitters; * tx_params a structure holding transmitter-specific configuration * parameters.- * */ void coverage (Parameters *params, Tx_parameters *tx_params, const int rank) { // // execute the path-loss calculation on CPU or GPU? // if (params->use_gpu) { // // initialize the OpenCL environment // init_gpu (params, tx_params, rank % 2); // // SIMULATE the LOS calculation on GPU // DoProfile_gpu (tx_params->m_obst_height, tx_params->m_obst_dist, tx_params->m_obst_offset, 1.0, tx_params->m_dem, tx_params->tx_north_coord_idx, tx_params->tx_east_coord_idx, tx_params->total_tx_height, tx_params->nrows, tx_params->ncols, params->map_ew_res, params->radius); #ifdef _PERFORMANCE_METRICS_ measure_time ("E/// on GPU"); #endif eric_pathloss_on_gpu (params, tx_params); } else { // // calculate the terrain profile from the top of the transmitter, // i.e. line-of-sight, only once per transmitter // DoProfile (tx_params->m_obst_height, tx_params->m_obst_dist, tx_params->m_obst_offset, 1.0, tx_params->m_dem, tx_params->tx_north_coord_idx, tx_params->tx_east_coord_idx, tx_params->total_tx_height, tx_params->nrows, tx_params->ncols, params->map_ew_res, params->radius); #ifdef _PERFORMANCE_METRICS_ measure_time ("E/// on CPU"); #endif eric_pathloss_on_cpu (params, tx_params); } #ifdef _PERFORMANCE_METRICS_ measure_time (NULL); #endif // // calculate the antenna influence, // overwriting the isotrophic path-loss // #ifdef _PERFORMANCE_METRICS_ measure_time ("Antenna influence"); #endif calculate_antenna_influence (params, tx_params); #ifdef _PERFORMANCE_METRICS_ measure_time (NULL); #endif // // if the coverage calculation happened on the GPU, // we need to refresh the memory buffers on the host // if (params->use_gpu) { size_t buff_size = tx_params->nrows * tx_params->ncols * sizeof (tx_params->m_loss[0][0]); read_buffer_blocking (tx_params->ocl_obj, 0, tx_params->m_loss_dev, buff_size, tx_params->m_loss[0]); } }
/* * Determine which clients (if any) have sent data to the server and handle it * as required. */ void HandleClientInput(__pmFdSet *fdsPtr) { int sts; int i; __pmPDU *pb; __pmPDUHdr *php; ClientInfo *cp; for (i = 0; i < nClients; i++) { int pinpdu; if (!client[i].status.connected || !__pmFD_ISSET(client[i].fd, fdsPtr)) continue; cp = &client[i]; this_client_id = i; pinpdu = sts = __pmGetPDU(cp->fd, LIMIT_SIZE, _pmcd_timeout, &pb); if (sts > 0) { pmcd_trace(TR_RECV_PDU, cp->fd, sts, (int)((__psint_t)pb & 0xffffffff)); } else { CleanupClient(cp, sts); continue; } php = (__pmPDUHdr *)pb; if (__pmVersionIPC(cp->fd) == UNKNOWN_VERSION && php->type != PDU_CREDS) { /* old V1 client protocol, no longer supported */ sts = PM_ERR_IPC; CleanupClient(cp, sts); __pmUnpinPDUBuf(pb); continue; } if (pmDebug & DBG_TRACE_APPL0) ShowClients(stderr); switch (php->type) { case PDU_PROFILE: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoProfile(cp, pb); break; case PDU_FETCH: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoFetch(cp, pb); break; case PDU_INSTANCE_REQ: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoInstance(cp, pb); break; case PDU_DESC_REQ: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoDesc(cp, pb); break; case PDU_TEXT_REQ: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoText(cp, pb); break; case PDU_RESULT: sts = (cp->denyOps & PMCD_OP_STORE) ? PM_ERR_PERMISSION : DoStore(cp, pb); break; case PDU_PMNS_IDS: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoPMNSIDs(cp, pb); break; case PDU_PMNS_NAMES: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoPMNSNames(cp, pb); break; case PDU_PMNS_CHILD: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoPMNSChild(cp, pb); break; case PDU_PMNS_TRAVERSE: sts = (cp->denyOps & PMCD_OP_FETCH) ? PM_ERR_PERMISSION : DoPMNSTraverse(cp, pb); break; case PDU_CREDS: sts = DoCreds(cp, pb); break; default: sts = PM_ERR_IPC; } if (sts < 0) { if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "PDU: %s client[%d]: %s\n", __pmPDUTypeStr(php->type), i, pmErrStr(sts)); /* Make sure client still alive before sending. */ if (cp->status.connected) { pmcd_trace(TR_XMIT_PDU, cp->fd, PDU_ERROR, sts); sts = __pmSendError(cp->fd, FROM_ANON, sts); if (sts < 0) __pmNotifyErr(LOG_ERR, "HandleClientInput: " "error sending Error PDU to client[%d] %s\n", i, pmErrStr(sts)); } } if (pinpdu > 0) __pmUnpinPDUBuf(pb); } }