Skip to content

Commit e08c13f

Browse files
committed
update identation
1 parent 1d3ec34 commit e08c13f

File tree

1 file changed

+41
-44
lines changed

1 file changed

+41
-44
lines changed

src/mpi-base.jl

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ typealias MPIDatatype Union{Char,
1010
# accessor function for getting MPI datatypes
1111
# use a function in case more behavior is needed later
1212
function mpitype{T}(::Type{T})
13-
return mpitype_dict[T]
13+
return mpitype_dict[T]
1414
end
1515

1616
type Comm
@@ -119,58 +119,55 @@ function Comm_size(comm::Comm)
119119
end
120120

121121
function type_create(T::DataType)
122+
if !isbits(T)
123+
throw(ArgumentError("Type must be isbits()"))
124+
end
122125

123-
if !isbits(T)
124-
throw(ArgumentError("Type must be isbits()"))
125-
end
126-
127-
if haskey(mpitype_dict, T) # if the datatype already exists
128-
return nothing
129-
end
130-
131-
# get the data from the type
132-
fieldtypes = T.types
133-
offsets = fieldoffsets(T)
134-
nfields = Cint(length(fieldtypes))
135-
136-
# put data in MPI format
137-
blocklengths = ones(Cint, nfields)
138-
displacements = zeros(Cptrdiff_t, nfields) # size_t == MPI_Aint ?
139-
types = zeros(Cint, nfields)
140-
for i=1:nfields
141-
displacements[i] = offsets[i]
142-
143-
# create an MPI_Datatype for the current field if it does not exist yet
144-
if !haskey(mpitype_dict, fieldtypes[i])
145-
type_create(fieldtypes[i])
126+
if haskey(mpitype_dict, T) # if the datatype already exists
127+
return nothing
146128
end
147129

148-
types[i] = mpitype(fieldtypes[i])
149-
end
130+
# get the data from the type
131+
fieldtypes = T.types
132+
offsets = fieldoffsets(T)
133+
nfields = Cint(length(fieldtypes))
134+
135+
# put data in MPI format
136+
blocklengths = ones(Cint, nfields)
137+
displacements = zeros(Cptrdiff_t, nfields) # size_t == MPI_Aint ?
138+
types = zeros(Cint, nfields)
139+
for i=1:nfields
140+
displacements[i] = offsets[i]
141+
# create an MPI_Datatype for the current field if it does not exist yet
142+
if !haskey(mpitype_dict, fieldtypes[i])
143+
type_create(fieldtypes[i])
144+
end
145+
types[i] = mpitype(fieldtypes[i])
146+
end
150147

151-
# create the datatype
152-
newtype_ref = Ref{Cint}()
153-
flag = Ref{Cint}()
154-
ccall(MPI_TYPE_CREATE_STRUCT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cptrdiff_t},
155-
Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), &nfields, blocklengths, displacements, types,
156-
newtype_ref, flag)
148+
# create the datatype
149+
newtype_ref = Ref{Cint}()
150+
flag = Ref{Cint}()
151+
ccall(MPI_TYPE_CREATE_STRUCT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cptrdiff_t},
152+
Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), &nfields, blocklengths, displacements,
153+
types, newtype_ref, flag)
157154

158-
if flag[] != 0
159-
throw(ErrorException("MPI_Type_create_struct returned non-zero exit status"))
160-
end
155+
if flag[] != 0
156+
throw(ErrorException("MPI_Type_create_struct returned non-zero exit status"))
157+
end
161158

162-
# commit the datatatype
163-
flag2 = Ref{Cint}()
164-
ccall(MPI_TYPE_COMMIT, Void, (Ptr{Cint}, Ptr{Cint}), newtype_ref, flag2)
159+
# commit the datatatype
160+
flag2 = Ref{Cint}()
161+
ccall(MPI_TYPE_COMMIT, Void, (Ptr{Cint}, Ptr{Cint}), newtype_ref, flag2)
165162

166-
if flag2[] != 0
167-
throw(ErrorException("MPI_Type_commit returned non-zero exit status"))
168-
end
163+
if flag2[] != 0
164+
throw(ErrorException("MPI_Type_commit returned non-zero exit status"))
165+
end
169166

170-
# add it to the dictonary of known types
171-
mpitype_dict[T] = newtype_ref[]
167+
# add it to the dictonary of known types
168+
mpitype_dict[T] = newtype_ref[]
172169

173-
return nothing
170+
return nothing
174171
end
175172

176173

0 commit comments

Comments
 (0)