MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / rectDivision

Function rectDivision

src/library/blas/generic/solution_seq_make.c:868–974  ·  view source on GitHub ↗

Rectangular division is done according to the picture: * * +------+-----+ * | | 2 | * | | | * | 1 +--+--+ * | |3 | 4| * | | | | * +------+--+--+ * * The longest side is divided first. */

Source from the content-addressed store, hash-verified

866 * The longest side is divided first.
867 */
868static void
869rectDivision(
870 BlasFunctionID funcID,
871 const CLBlasKargs *args,
872 ListHead *seq,
873 cl_uint totalCUs)
874 {
875 SolutionStep *step, **sortedSteps;
876 ListNode *i, *j;
877 cl_int err;
878 cl_device_id device;
879 cl_uint nrCU, k, l;
880 SubproblemDim size, offset, stepSize;
881 unsigned int nrSteps = 0;
882
883 /* 1. Sort steps according to the number of CU they have */
884 /* NOTE: We expect small number of steps, so simple insertion sort
885 * would be enough.
886 */
887
888 sortedSteps = calloc(listLength(seq), sizeof(*sortedSteps));
889 // assert(sortedSteps != NULL);
890
891 k = 0;
892 for (i = listNodeFirst(seq); i != seq; i = i->next, nrSteps++) {
893 step = container_of(i, node, SolutionStep);
894 err = getQueueDevice(step->cmdQueue, &device);
895
896 sortedSteps[k] = step;
897 nrCU = deviceComputeUnits(device, &err);
898
899 for (j = i->next; j != seq; j = j->next) {
900 step = container_of(i, node, SolutionStep);
901 err = getQueueDevice(step->cmdQueue, &device);
902
903 if (nrCU < deviceComputeUnits(device, &err)) {
904 sortedSteps[k] = step;
905 nrCU = deviceComputeUnits(device, &err);
906 }
907 }
908
909 k++;
910 }
911
912 /* 2. Calculate rectangle sizes */
913
914 kargsToProbDims(&offset, funcID, args, true);
915 kargsToProbDims(&size, funcID, args, false);
916 stepSize = size;
917
918 for (l = 0; l < k; l++) {
919 step = sortedSteps[l];
920 err = getQueueDevice(step->cmdQueue, &device);
921 nrCU = deviceComputeUnits(device, &err);
922
923 if (totalCUs == 0) {
924 step->cmdQueue = NULL;
925 continue;

Callers 1

makeSolutionSeqFunction · 0.85

Calls 7

listLengthFunction · 0.85
listNodeFirstFunction · 0.85
getQueueDeviceFunction · 0.85
deviceComputeUnitsFunction · 0.85
kargsToProbDimsFunction · 0.85
probDimsToKargsFunction · 0.85
alignFunction · 0.85

Tested by

no test coverage detected