Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
7df0f527
Commit
7df0f527
authored
27 years ago
by
dtc
Browse files
Options
Downloads
Patches
Plain Diff
New-random tuning; with latest propagate-float-type code can inline to
32 bits on x86 and 31 on other ports.
parent
ce96dd38
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
code/exports.lisp
+2
-2
2 additions, 2 deletions
code/exports.lisp
code/rand.lisp
+12
-9
12 additions, 9 deletions
code/rand.lisp
compiler/float-tran.lisp
+13
-3
13 additions, 3 deletions
compiler/float-tran.lisp
with
27 additions
and
14 deletions
code/exports.lisp
+
2
−
2
View file @
7df0f527
...
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/exports.lisp,v 1.1
19
1997/06/
03 19:11:26
dtc Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/exports.lisp,v 1.1
20
1997/06/
11 18:32:18
dtc Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -1566,7 +1566,7 @@
"CLASS-DIRECT-SUPERCLASSES"
"MAKE-LAYOUT"
"SIMPLE-STYLE-WARNING"
"BYTE-FUNCTION-TYPE"
"SLOT-CLASS-PRINT-FUNCTION"
"REDEFINE-LAYOUT-WARNING"
"SLOT-CLASS"
"INSURED-FIND-CLASS"
"CONDITION-FUNCTION-NAME"
"RANDOM-CHUNK-MAX"
))
"CONDITION-FUNCTION-NAME"
))
(
dolist
(
name
...
...
This diff is collapsed.
Click to expand it.
code/rand.lisp
+
12
−
9
View file @
7df0f527
...
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/rand.lisp,v 1.
9
1997/06/
05 00:20:52
dtc Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/rand.lisp,v 1.
10
1997/06/
11 18:32:14
dtc Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -239,7 +239,7 @@
#+
new-random
(
in-package
"KERNEL"
)
#+
new-random
(
export
'
(
%random-single-float
%random-double-float
random-chunk-max
))
(
export
'
(
%random-single-float
%random-double-float
))
#+
new-random
...
...
@@ -479,14 +479,17 @@
;;;; Random integers:
;;; We generate a random float and extract this many bits from it. The
;;; random integer is created by concatenating a bunch of these
;;; together. 31 has the nice property that Python doesn't have to
;;; box it up, and that Python can optimize the truncate call because
;;; the result is a (signed-byte 32).
;;; Random integers are created by concatenating a bunch of chunks
;;; together. Chunks are generated without consing by truncating a
;;; random float to an integer. With the latest propagate-float-type
;;; code the compiler can inline truncate (signed-byte 32) allowing 31
;;; bits, and (unsigned-byte 32) 32 bits on the x86. When not using the
;;; propagate-float-type feature the best size that can be inlined is
;;; 29 bits. Use of sizes greater than 29 bits causes consing in
;;; argument passing to generic functions, so 29 bits is a good
;;; default.
;;;
(
defconstant
random-chunk-size
29
)
(
defconstant
random-chunk-max
(
1-
(
expt
2
random-chunk-size
)))
;;; %RANDOM-INTEGER -- Internal
;;;
...
...
@@ -497,7 +500,7 @@
(
declare
(
type
(
integer
1
)
arg
)
(
type
random-state
state
))
(
flet
((
random-chunk
(
state
)
(
values
(
truncate
(
*
(
float
(
1+
random-chunk-
max
)
1d0
)
(
values
(
truncate
(
*
(
float
(
expt
2
random-chunk-
size
)
1d0
)
(
new-random-float
state
))))))
(
let
((
shift
random-chunk-size
))
(
do
((
bits
(
random-chunk
state
)
...
...
This diff is collapsed.
Click to expand it.
compiler/float-tran.lisp
+
13
−
3
View file @
7df0f527
...
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/float-tran.lisp,v 1.3
0
1997/06/
03 19:11:29
dtc Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/float-tran.lisp,v 1.3
1
1997/06/
11 18:32:24
dtc Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -78,10 +78,20 @@
"use inline fixnum operations"
'
(
rem
(
random-chunk
(
or
state
*random-state*
))
num
))
;;; With the latest propagate-float-type code the compiler can inline
;;; truncate (signed-byte 32) allowing 31 bits, and (unsigned-byte 32)
;;; 32 bits on the x86. When not using the propagate-float-type
;;; feature the best size that can be inlined is 29 bits. The choice
;;; shouldn't cause bootstrap problems just slow code.
#+
new-random
(
deftransform
random
((
num
&optional
state
)
((
integer
1
#.
random-chunk-max
)
&optional
*
))
"use inline (signed-byte 32) operations"
((
integer
1
#+
(
and
propagate-float-type
x86
)
#xffffffff
#+
(
and
propagate-float-type
(
not
x86
))
#x7fffffff
#-
propagate-float-type
#.
most-positive-fixnum
)
&optional
*
))
#+
x86
"use inline (unsigned-byte 32) operations"
#-
x86
"use inline (signed-byte 32) operations"
'
(
values
(
truncate
(
%random-double-float
(
coerce
num
'double-float
)
(
or
state
*random-state*
)))))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment