void ceDeviceGL20::DrawIndexPrimitives (cePrimitiveType pType, ceDataType iType, unsigned count, bool unbind) { assert(_vertexDeclaration); assert(_indices); for (unsigned i = 0, j = _vertexDeclaration->GetNumberOfStreams (); i < j; i++) { void* ptr = _vertexStreams[i]->Bind (); _vertexDeclaration->BindStream (_program, i, ptr); } _indices->Bind (); prim_type = convert_primitive_type (pType); prim_count = count; index_type = convert_data_type (iType); glDrawElements (prim_type, prim_count, index_type, 0); if (unbind) { for (unsigned i = 0, j = _vertexDeclaration->GetNumberOfStreams (); i < j; i++) { _vertexDeclaration->UnbindStream (_program, i); } } }
/** * \brief Helper function to check for restrictions on `gpudata` to be used in * nccl * collective operations. */ static inline int check_restrictions(gpudata *src, size_t offsrc, gpudata *dest, size_t offdest, size_t count, int typecode, int opcode, gpucomm *comm, ncclDataType_t *datatype, ncclRedOp_t *op) { size_t op_size; // Check if count is larger than INT_MAX // TODO remove whenif nccl adapts to size_t if (count > INT_MAX) return error_set(comm->ctx->err, GA_XLARGE_ERROR, "Count too large for int"); // src, dest and comm must refer to the same context if (src->ctx != comm->ctx) return error_set(comm->ctx->err, GA_VALUE_ERROR, "source and comm context differ"); if (dest != NULL && dest->ctx != comm->ctx) return error_set(comm->ctx->err, GA_VALUE_ERROR, "destination and comm context differ"); // typecode must correspond to a valid ncclDataType_t if (datatype != NULL) { *datatype = convert_data_type(typecode); if (*datatype == ncclNumTypes) return error_set(comm->ctx->err, GA_INVALID_ERROR, "Invalid data type"); } // opcode must correspond to a valid ncclRedOp_t if (op != NULL) { *op = convert_reduce_op(opcode); if (*op == ncclNumOps) return error_set(comm->ctx->err, GA_INVALID_ERROR, "Invalid reduce op"); } // offsets must not be larger than gpudata's size itself // (else out of alloc-ed mem scope) assert(!(offsrc > src->sz)); assert(!(dest != NULL && offdest > dest->sz)); // size to operate upon must be able to fit inside the gpudata (incl offsets) op_size = count * gpuarray_get_elsize(typecode); if ((src->sz - offsrc) < op_size) return error_set(comm->ctx->err, GA_VALUE_ERROR, "source too small for operation"); if (dest != NULL && (dest->sz - offdest) < op_size) return error_set(comm->ctx->err, GA_VALUE_ERROR, "destination too small for operation"); return GA_NO_ERROR; }