J3/04-129 Date: 13 Dec. 2003 To: J3 From: Dan Nagle Subject: HPF Intrinsics This proposal is to incorporate the HPF operations ceiling division and ceiling remainder. Number: Title: Ceiling Division and Ceiling Remainder Submitted By: J3 Status: For Consideration References: HPF (See, e.g., _The High Performance Fortran Handbook_, Koelbel, C. H., et al. page 107) Also, see Sections 13.7.80 MOD, 13.7.81 MODULO Basic Functionality: Ceiling Division is a kind of integer devision, rather than truncating the quotient, it is rounded upwards. Ceiling Remainder is (always zero or negative) remainder after Ceiling Division. Rationale: When dividing something into groups, one often has a size characteristic of the containers used. For example, one might ask how many egg cartons is needed to hold an arbitrary number of eggs. To hold 42 eggs, one needs 4 cartons (which can hold a dozen eggs each). This problem is often encountered when a parallel program assigns computations to processors. Ceiling Division is the operation providing the answer. Ceiling Remainder is the number of empty spaces left over, expressed as a negative number (so number = quotient * divisor + remainder always holds). Estimated Impact: These are two more intrinsics to be supported. Detailed Specification: Add two new intrinsics: CDIV and CREM. CDIV( A, P) A, P are integers of any kind Result is A/P if the remainder is zero, otherwise the result is A/P + 1 CREM( A, P) A, P are integers of any kind Result is A - CDIV( A, P) * P Example: type( bigwork_t), dimension( n) :: work_items work_per_processor = cdiv( n, number_of_processors) History: