Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

OpenCL overloads "fabs", "sin", etc. for both floats and doubles inst…

…ead of postfixing an "f"
  • Loading branch information...
commit 9e27d41fdcf4074503d84df1f5e5ce04760d2586 1 parent 8ed3b52
Martin Dybdal dybber authored

Showing 1 changed file with 26 additions and 31 deletions. Show diff stats Hide diff stats

  1. +26 31 Data/Array/Accelerate/OpenCL/CodeGen.hs
57 Data/Array/Accelerate/OpenCL/CodeGen.hs
@@ -423,25 +423,25 @@ codeGenPrim (PrimBRotateL _) [a,b] = ccall "rotateL" [a,b]
423 423 codeGenPrim (PrimBRotateR _) [a,b] = ccall "rotateR" [a,b]
424 424 codeGenPrim (PrimFDiv _) [a,b] = [cexp|$exp:a / $exp:b|]
425 425 codeGenPrim (PrimRecip ty) [a] = codeGenRecip ty a
426   -codeGenPrim (PrimSin ty) [a] = ccall (FloatingNumType ty `postfix` "sin") [a]
427   -codeGenPrim (PrimCos ty) [a] = ccall (FloatingNumType ty `postfix` "cos") [a]
428   -codeGenPrim (PrimTan ty) [a] = ccall (FloatingNumType ty `postfix` "tan") [a]
429   -codeGenPrim (PrimAsin ty) [a] = ccall (FloatingNumType ty `postfix` "asin") [a]
430   -codeGenPrim (PrimAcos ty) [a] = ccall (FloatingNumType ty `postfix` "acos") [a]
431   -codeGenPrim (PrimAtan ty) [a] = ccall (FloatingNumType ty `postfix` "atan") [a]
432   -codeGenPrim (PrimAsinh ty) [a] = ccall (FloatingNumType ty `postfix` "asinh") [a]
433   -codeGenPrim (PrimAcosh ty) [a] = ccall (FloatingNumType ty `postfix` "acosh") [a]
434   -codeGenPrim (PrimAtanh ty) [a] = ccall (FloatingNumType ty `postfix` "atanh") [a]
435   -codeGenPrim (PrimExpFloating ty) [a] = ccall (FloatingNumType ty `postfix` "exp") [a]
436   -codeGenPrim (PrimSqrt ty) [a] = ccall (FloatingNumType ty `postfix` "sqrt") [a]
437   -codeGenPrim (PrimLog ty) [a] = ccall (FloatingNumType ty `postfix` "log") [a]
438   -codeGenPrim (PrimFPow ty) [a,b] = ccall (FloatingNumType ty `postfix` "pow") [a,b]
  426 +codeGenPrim (PrimSin ty) [a] = ccall "sin" [a]
  427 +codeGenPrim (PrimCos ty) [a] = ccall "cos" [a]
  428 +codeGenPrim (PrimTan ty) [a] = ccall "tan" [a]
  429 +codeGenPrim (PrimAsin ty) [a] = ccall "asin" [a]
  430 +codeGenPrim (PrimAcos ty) [a] = ccall "acos" [a]
  431 +codeGenPrim (PrimAtan ty) [a] = ccall "atan" [a]
  432 +codeGenPrim (PrimAsinh ty) [a] = ccall "asinh" [a]
  433 +codeGenPrim (PrimAcosh ty) [a] = ccall "acosh" [a]
  434 +codeGenPrim (PrimAtanh ty) [a] = ccall "atanh" [a]
  435 +codeGenPrim (PrimExpFloating ty) [a] = ccall "exp" [a]
  436 +codeGenPrim (PrimSqrt ty) [a] = ccall "sqrt" [a]
  437 +codeGenPrim (PrimLog ty) [a] = ccall "log" [a]
  438 +codeGenPrim (PrimFPow ty) [a,b] = ccall "pow" [a,b]
439 439 codeGenPrim (PrimLogBase ty) [a,b] = codeGenLogBase ty a b
440 440 codeGenPrim (PrimTruncate ta tb) [a] = codeGenTruncate ta tb a
441 441 codeGenPrim (PrimRound ta tb) [a] = codeGenRound ta tb a
442 442 codeGenPrim (PrimFloor ta tb) [a] = codeGenFloor ta tb a
443 443 codeGenPrim (PrimCeiling ta tb) [a] = codeGenCeiling ta tb a
444   -codeGenPrim (PrimAtan2 ty) [a,b] = ccall (FloatingNumType ty `postfix` "atan2") [a,b]
  444 +codeGenPrim (PrimAtan2 ty) [a,b] = ccall "atan2" [a,b]
445 445 codeGenPrim (PrimLt _) [a,b] = [cexp|$exp:a < $exp:b|]
446 446 codeGenPrim (PrimGt _) [a,b] = [cexp|$exp:a > $exp:b|]
447 447 codeGenPrim (PrimLtEq _) [a,b] = [cexp|$exp:a <= $exp:b|]
@@ -523,8 +523,8 @@ codeGenMaxBound (NonNumBoundedType ty)
523 523 -- Methods from Num, Floating, Fractional and RealFrac
524 524
525 525 codeGenAbs :: NumType a -> C.Exp -> C.Exp
526   -codeGenAbs ty@(IntegralNumType _) x = ccall (ty `postfix` "abs") [x]
527   -codeGenAbs ty@(FloatingNumType _) x = ccall (ty `postfix` "fabs") [x]
  526 +codeGenAbs ty@(IntegralNumType _) x = ccall "abs" [x]
  527 +codeGenAbs ty@(FloatingNumType _) x = ccall "fabs" [x]
528 528
529 529 -- TODO investigate whether codeGenScalar should be necessary
530 530 codeGenSig :: NumType a -> C.Exp -> C.Exp
@@ -545,20 +545,20 @@ codeGenRecip ty x | FloatingDict <- floatingDict ty
545 545 in [cexp| $exp:a / $exp:x |]
546 546
547 547 codeGenLogBase :: FloatingType a -> C.Exp -> C.Exp -> C.Exp
548   -codeGenLogBase ty x y = let a = ccall (FloatingNumType ty `postfix` "log") [x]
549   - b = ccall (FloatingNumType ty `postfix` "log") [y]
  548 +codeGenLogBase ty x y = let a = ccall "log" [x]
  549 + b = ccall "log" [y]
550 550 in [cexp| $exp:b / $exp:a |]
551 551
552 552 codeGenMin :: ScalarType a -> C.Exp -> C.Exp -> C.Exp
553   -codeGenMin (NumScalarType ty@(IntegralNumType _)) a b = ccall (ty `postfix` "min") [a,b]
554   -codeGenMin (NumScalarType ty@(FloatingNumType _)) a b = ccall (ty `postfix` "fmin") [a,b]
  553 +codeGenMin (NumScalarType ty@(IntegralNumType _)) a b = ccall "min" [a,b]
  554 +codeGenMin (NumScalarType ty@(FloatingNumType _)) a b = ccall "fmin" [a,b]
555 555 codeGenMin (NonNumScalarType _) a b =
556 556 let ty = NumScalarType (IntegralNumType (TypeInt32 (undefined :: IntegralDict Int32)))
557 557 in codeGenMin ty (ccast ty a) (ccast ty b)
558 558
559 559 codeGenMax :: ScalarType a -> C.Exp -> C.Exp -> C.Exp
560   -codeGenMax (NumScalarType ty@(IntegralNumType _)) a b = ccall (ty `postfix` "max") [a,b]
561   -codeGenMax (NumScalarType ty@(FloatingNumType _)) a b = ccall (ty `postfix` "fmax") [a,b]
  560 +codeGenMax (NumScalarType ty@(IntegralNumType _)) a b = ccall "max" [a,b]
  561 +codeGenMax (NumScalarType ty@(FloatingNumType _)) a b = ccall "fmax" [a,b]
562 562 codeGenMax (NonNumScalarType _) a b =
563 563 let ty = NumScalarType (IntegralNumType (TypeInt32 (undefined :: IntegralDict Int32)))
564 564 in codeGenMax ty (ccast ty a) (ccast ty b)
@@ -581,22 +581,22 @@ codeGenFromIntegral _ ty = ccast (NumScalarType ty)
581 581 codeGenTruncate :: FloatingType a -> IntegralType b -> C.Exp -> C.Exp
582 582 codeGenTruncate ta tb x
583 583 = ccast (NumScalarType (IntegralNumType tb))
584   - $ ccall (FloatingNumType ta `postfix` "trunc") [x]
  584 + $ ccall "trunc" [x]
585 585
586 586 codeGenRound :: FloatingType a -> IntegralType b -> C.Exp -> C.Exp
587 587 codeGenRound ta tb x
588 588 = ccast (NumScalarType (IntegralNumType tb))
589   - $ ccall (FloatingNumType ta `postfix` "round") [x]
  589 + $ ccall "round" [x]
590 590
591 591 codeGenFloor :: FloatingType a -> IntegralType b -> C.Exp -> C.Exp
592 592 codeGenFloor ta tb x
593 593 = ccast (NumScalarType (IntegralNumType tb))
594   - $ ccall (FloatingNumType ta `postfix` "floor") [x]
  594 + $ ccall "floor" [x]
595 595
596 596 codeGenCeiling :: FloatingType a -> IntegralType b -> C.Exp -> C.Exp
597 597 codeGenCeiling ta tb x
598 598 = ccast (NumScalarType (IntegralNumType tb))
599   - $ ccall (FloatingNumType ta `postfix` "ceil") [x]
  599 + $ ccall "ceil" [x]
600 600
601 601
602 602 -- Auxiliary Functions
@@ -606,8 +606,3 @@ ccast :: ScalarType a -> C.Exp -> C.Exp
606 606 ccast ty x = [cexp|($ty:t) $exp:x|]
607 607 where t = codeGenScalarType ty
608 608
609   -postfix :: NumType a -> String -> String
610   -postfix (FloatingNumType (TypeFloat _)) = (++ "f")
611   -postfix (FloatingNumType (TypeCFloat _)) = (++ "f")
612   -postfix _ = id
613   -

0 comments on commit 9e27d41

Please sign in to comment.
Something went wrong with that request. Please try again.