Let us assume that the user wants to sort an array of integers with NetSolve using the C interface. The default NetSolve server comes with a default problem called iqsort that does a quicksort on an integer vector. The call looks like
status = netsl('iqsort()',size,ptr,sorted); |
requests1 = netslnb('iqsort',size1,ptr1,sorted1); requests2 = netslnb('iqsort',size2,ptr2,sorted2); ... requests200 = netslnb('iqsort',size200,array200,sorted200); |
With farming, one only needs to construct three arrays as:
int size_array[200]; void *ptr_array[200]; void *sorted_array[200]; size_array[0] = size1; ptr_array[0] = ptr1; sorted_array[0] = sorted1; ... |
Then, netsl_farm() can be called as:
status_array = netsl_farm("i=0,199",netsl_int_array(size_array,"$i"), netsl_ptr_array(ptr_array,"$i"), netsl_ptr_array(sorted_array,"$i")); |
In short, netsl_farm() is a concise, convenient way of farming out groups of requests. Of course, it uses netslnb() underneath, thereby ensuring fault-tolerance and load-balancing.