Cleanup. Remove copyright year. Reformat.
This commit is contained in:
parent
a6a269703d
commit
9712d7e2c8
176
.clang-format
Normal file
176
.clang-format
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: WebKit
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
AlignConsecutiveBitFields: None
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: Consecutive
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: OnlyFirstIf
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: WebKit
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 90
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
BasedOnStyle: ''
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
FixNamespaceComments: false
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 200
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PointerAlignment: Left
|
||||||
|
PPIndentWidth: -1
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
Standard: Latest
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- STRINGIZE
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
...
|
14
.clang-tidy
Normal file
14
.clang-tidy
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
Checks: 'clang-diagnostic-*,clang-analyzer-*,clang-bugprone-*,readability-identifier-naming'
|
||||||
|
WarningsAsErrors: true
|
||||||
|
HeaderFilterRegex: '.*'
|
||||||
|
AnalyzeTemporaryDtors: false
|
||||||
|
CheckOptions:
|
||||||
|
- key: readability-identifier-naming.StructCase
|
||||||
|
value: 'CamelCase'
|
||||||
|
- key: readability-identifier-naming.FunctionCase
|
||||||
|
value: 'camelBack'
|
||||||
|
- key: readability-identifier-naming.VariableCase
|
||||||
|
value: 'camelBack'
|
||||||
|
- key: readability-identifier-naming.GlobalConstantCase
|
||||||
|
value: 'UPPER_CASE'
|
3
.clangd
Normal file
3
.clangd
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
CompileFlags:
|
||||||
|
Add: [-I/Users/jan/prg/MD-Bench/verletlist/includes, -I/Users/jan/prg/MD-Bench/common/includes, -DALIGNMENT=64]
|
||||||
|
Compiler: clang
|
4
Makefile
4
Makefile
@ -98,10 +98,6 @@ ifeq ($(strip $(ENABLE_OMP_SIMD)),true)
|
|||||||
DEFINES += -DENABLE_OMP_SIMD
|
DEFINES += -DENABLE_OMP_SIMD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(USE_SIMD_KERNEL)),true)
|
|
||||||
DEFINES += -DUSE_SIMD_KERNEL
|
|
||||||
endif
|
|
||||||
|
|
||||||
VPATH = $(SRC_DIR) $(ASM_DIR) $(CUDA_DIR)
|
VPATH = $(SRC_DIR) $(ASM_DIR) $(CUDA_DIR)
|
||||||
ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c))
|
ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c))
|
||||||
OVERWRITE:= $(patsubst $(ASM_DIR)/%-new.s, $(BUILD_DIR)/%.o,$(wildcard $(ASM_DIR)/*-new.s))
|
OVERWRITE:= $(patsubst $(ASM_DIR)/%-new.s, $(BUILD_DIR)/%.o,$(wildcard $(ASM_DIR)/*-new.s))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
@ -7,40 +7,41 @@
|
|||||||
#ifndef __UTIL_H_
|
#ifndef __UTIL_H_
|
||||||
#define __UTIL_H_
|
#define __UTIL_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
# define MIN(x,y) ((x)<(y)?(x):(y))
|
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
# define MAX(x,y) ((x)>(y)?(x):(y))
|
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ABS
|
#ifndef ABS
|
||||||
# define ABS(a) ((a) >= 0 ? (a) : -(a))
|
#define ABS(a) ((a) >= 0 ? (a) : -(a))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEBUG_MESSAGE debug_printf
|
#define DEBUG_MESSAGE debug_printf
|
||||||
|
|
||||||
#ifndef MAXLINE
|
#ifndef MAXLINE
|
||||||
# define MAXLINE 4096
|
#define MAXLINE 4096
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FF_LJ 0
|
#define FF_LJ 0
|
||||||
#define FF_EAM 1
|
#define FF_EAM 1
|
||||||
#define FF_DEM 2
|
#define FF_DEM 2
|
||||||
|
|
||||||
#if PRECISION == 1
|
#if PRECISION == 1
|
||||||
# define PRECISION_STRING "single"
|
#define PRECISION_STRING "single"
|
||||||
#else
|
#else
|
||||||
# define PRECISION_STRING "double"
|
#define PRECISION_STRING "double"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern double myrandom(int*);
|
extern double myrandom(int *);
|
||||||
extern void random_reset(int *seed, int ibase, double *coord);
|
extern void random_reset(int *seed, int ibase, double *coord);
|
||||||
extern int str2ff(const char *string);
|
extern int str2ff(const char *string);
|
||||||
extern const char* ff2str(int ff);
|
extern const char *ff2str(int ff);
|
||||||
extern void readline(char *line, FILE *fp);
|
extern void readline(char *line, FILE *fp);
|
||||||
extern void debug_printf(const char *format, ...);
|
extern void debug_printf(const char *format, ...);
|
||||||
extern int get_cuda_num_threads();
|
extern int get_cuda_num_threads(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
14
config.mk
14
config.mk
@ -1,17 +1,17 @@
|
|||||||
# Compiler tag (GCC/CLANG/ICC/ICX/ONEAPI/NVCC)
|
# Compiler tag (GCC/CLANG/ICC/ICX/ONEAPI/NVCC)
|
||||||
TAG ?= ICC
|
TAG ?= CLANG
|
||||||
# Instruction set (SSE/AVX/AVX_FMA/AVX2/AVX512)
|
# Instruction set (SSE/AVX/AVX_FMA/AVX2/AVX512)
|
||||||
ISA ?= AVX512
|
ISA ?= SSE
|
||||||
# Optimization scheme (lammps/gromacs/clusters_per_bin)
|
# Optimization scheme (verletlist/clusterpair/clusters_per_bin)
|
||||||
OPT_SCHEME ?= lammps
|
OPT_SCHEME ?= verletlist
|
||||||
# Enable likwid (true or false)
|
# Enable likwid (true or false)
|
||||||
ENABLE_LIKWID ?= true
|
ENABLE_LIKWID ?= false
|
||||||
# SP or DP
|
# SP or DP
|
||||||
DATA_TYPE ?= DP
|
DATA_TYPE ?= DP
|
||||||
# AOS or SOA
|
# AOS or SOA
|
||||||
DATA_LAYOUT ?= AOS
|
DATA_LAYOUT ?= AOS
|
||||||
# Assembly syntax to generate (ATT/INTEL)
|
# Assembly syntax to generate (ATT/INTEL)
|
||||||
ASM_SYNTAX ?= ATT
|
ASM_SYNTAX ?= INTEL
|
||||||
# Debug
|
# Debug
|
||||||
DEBUG ?= false
|
DEBUG ?= false
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ COMPUTE_STATS ?= true
|
|||||||
|
|
||||||
# Configurations for lammps optimization scheme
|
# Configurations for lammps optimization scheme
|
||||||
# Use omp simd pragma when running with half neighbor-lists
|
# Use omp simd pragma when running with half neighbor-lists
|
||||||
ENABLE_OMP_SIMD ?= true
|
ENABLE_OMP_SIMD ?= false
|
||||||
# Use kernel with explicit SIMD intrinsics
|
# Use kernel with explicit SIMD intrinsics
|
||||||
USE_SIMD_KERNEL ?= false
|
USE_SIMD_KERNEL ?= false
|
||||||
|
|
||||||
|
@ -1,278 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
|
||||||
* license that can be found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
//---
|
|
||||||
#include <atom.h>
|
|
||||||
#include <likwid-marker.h>
|
|
||||||
#include <neighbor.h>
|
|
||||||
#include <parameter.h>
|
|
||||||
#include <stats.h>
|
|
||||||
#include <timing.h>
|
|
||||||
|
|
||||||
#ifdef __SIMD_KERNEL__
|
|
||||||
#include <simd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
double computeForceLJFullNeigh_plain_c(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
|
||||||
int Nlocal = atom->Nlocal;
|
|
||||||
int* neighs;
|
|
||||||
#ifndef EXPLICIT_TYPES
|
|
||||||
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
|
|
||||||
MD_FLOAT sigma6 = param->sigma6;
|
|
||||||
MD_FLOAT epsilon = param->epsilon;
|
|
||||||
#endif
|
|
||||||
const MD_FLOAT num1 = 1.0;
|
|
||||||
const MD_FLOAT num48 = 48.0;
|
|
||||||
const MD_FLOAT num05 = 0.5;
|
|
||||||
|
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
|
||||||
atom_fx(i) = 0.0;
|
|
||||||
atom_fy(i) = 0.0;
|
|
||||||
atom_fz(i) = 0.0;
|
|
||||||
}
|
|
||||||
double S = getTimeStamp();
|
|
||||||
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
|
||||||
LIKWID_MARKER_START("force");
|
|
||||||
|
|
||||||
#pragma omp for schedule(runtime)
|
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
|
||||||
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
|
||||||
int numneighs = neighbor->numneigh[i];
|
|
||||||
MD_FLOAT xtmp = atom_x(i);
|
|
||||||
MD_FLOAT ytmp = atom_y(i);
|
|
||||||
MD_FLOAT ztmp = atom_z(i);
|
|
||||||
MD_FLOAT fix = 0;
|
|
||||||
MD_FLOAT fiy = 0;
|
|
||||||
MD_FLOAT fiz = 0;
|
|
||||||
|
|
||||||
#ifdef EXPLICIT_TYPES
|
|
||||||
const int type_i = atom->type[i];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for(int k = 0; k < numneighs; k++) {
|
|
||||||
int j = neighs[k];
|
|
||||||
MD_FLOAT delx = xtmp - atom_x(j);
|
|
||||||
MD_FLOAT dely = ytmp - atom_y(j);
|
|
||||||
MD_FLOAT delz = ztmp - atom_z(j);
|
|
||||||
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
|
|
||||||
|
|
||||||
#ifdef EXPLICIT_TYPES
|
|
||||||
const int type_j = atom->type[j];
|
|
||||||
const int type_ij = type_i * atom->ntypes + type_j;
|
|
||||||
const MD_FLOAT cutforcesq = atom->cutforcesq[type_ij];
|
|
||||||
const MD_FLOAT sigma6 = atom->sigma6[type_ij];
|
|
||||||
const MD_FLOAT epsilon = atom->epsilon[type_ij];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(rsq < cutforcesq) {
|
|
||||||
MD_FLOAT sr2 = num1 / rsq;
|
|
||||||
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
|
|
||||||
MD_FLOAT force = num48 * sr6 * (sr6 - num05) * sr2 * epsilon;
|
|
||||||
fix += delx * force;
|
|
||||||
fiy += dely * force;
|
|
||||||
fiz += delz * force;
|
|
||||||
#ifdef USE_REFERENCE_VERSION
|
|
||||||
addStat(stats->atoms_within_cutoff, 1);
|
|
||||||
} else {
|
|
||||||
addStat(stats->atoms_outside_cutoff, 1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
atom_fx(i) += fix;
|
|
||||||
atom_fy(i) += fiy;
|
|
||||||
atom_fz(i) += fiz;
|
|
||||||
|
|
||||||
#ifdef USE_REFERENCE_VERSION
|
|
||||||
if(numneighs % VECTOR_WIDTH > 0) {
|
|
||||||
addStat(stats->atoms_outside_cutoff, VECTOR_WIDTH - (numneighs % VECTOR_WIDTH));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
addStat(stats->total_force_neighs, numneighs);
|
|
||||||
addStat(stats->total_force_iters, (numneighs + VECTOR_WIDTH - 1) / VECTOR_WIDTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
LIKWID_MARKER_STOP("force");
|
|
||||||
}
|
|
||||||
|
|
||||||
double E = getTimeStamp();
|
|
||||||
return E-S;
|
|
||||||
}
|
|
||||||
|
|
||||||
double computeForceLJHalfNeigh(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
|
||||||
int Nlocal = atom->Nlocal;
|
|
||||||
int* neighs;
|
|
||||||
#ifndef EXPLICIT_TYPES
|
|
||||||
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
|
|
||||||
MD_FLOAT sigma6 = param->sigma6;
|
|
||||||
MD_FLOAT epsilon = param->epsilon;
|
|
||||||
#endif
|
|
||||||
const MD_FLOAT num1 = 1.0;
|
|
||||||
const MD_FLOAT num48 = 48.0;
|
|
||||||
const MD_FLOAT num05 = 0.5;
|
|
||||||
|
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
|
||||||
atom_fx(i) = 0.0;
|
|
||||||
atom_fy(i) = 0.0;
|
|
||||||
atom_fz(i) = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double S = getTimeStamp();
|
|
||||||
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
|
||||||
LIKWID_MARKER_START("forceLJ-halfneigh");
|
|
||||||
|
|
||||||
#pragma omp for schedule(runtime)
|
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
|
||||||
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
|
||||||
int numneighs = neighbor->numneigh[i];
|
|
||||||
MD_FLOAT xtmp = atom_x(i);
|
|
||||||
MD_FLOAT ytmp = atom_y(i);
|
|
||||||
MD_FLOAT ztmp = atom_z(i);
|
|
||||||
MD_FLOAT fix = 0;
|
|
||||||
MD_FLOAT fiy = 0;
|
|
||||||
MD_FLOAT fiz = 0;
|
|
||||||
|
|
||||||
#ifdef EXPLICIT_TYPES
|
|
||||||
const int type_i = atom->type[i];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Pragma required to vectorize the inner loop
|
|
||||||
#ifdef ENABLE_OMP_SIMD
|
|
||||||
#pragma omp simd reduction(+: fix,fiy,fiz)
|
|
||||||
#endif
|
|
||||||
for(int k = 0; k < numneighs; k++) {
|
|
||||||
int j = neighs[k];
|
|
||||||
MD_FLOAT delx = xtmp - atom_x(j);
|
|
||||||
MD_FLOAT dely = ytmp - atom_y(j);
|
|
||||||
MD_FLOAT delz = ztmp - atom_z(j);
|
|
||||||
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
|
|
||||||
|
|
||||||
#ifdef EXPLICIT_TYPES
|
|
||||||
const int type_j = atom->type[j];
|
|
||||||
const int type_ij = type_i * atom->ntypes + type_j;
|
|
||||||
const MD_FLOAT cutforcesq = atom->cutforcesq[type_ij];
|
|
||||||
const MD_FLOAT sigma6 = atom->sigma6[type_ij];
|
|
||||||
const MD_FLOAT epsilon = atom->epsilon[type_ij];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(rsq < cutforcesq) {
|
|
||||||
MD_FLOAT sr2 = num1 / rsq;
|
|
||||||
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
|
|
||||||
MD_FLOAT force = num48 * sr6 * (sr6 - num05) * sr2 * epsilon;
|
|
||||||
fix += delx * force;
|
|
||||||
fiy += dely * force;
|
|
||||||
fiz += delz * force;
|
|
||||||
|
|
||||||
// We do not need to update forces for ghost atoms
|
|
||||||
if(j < Nlocal) {
|
|
||||||
atom_fx(j) -= delx * force;
|
|
||||||
atom_fy(j) -= dely * force;
|
|
||||||
atom_fz(j) -= delz * force;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
atom_fx(i) += fix;
|
|
||||||
atom_fy(i) += fiy;
|
|
||||||
atom_fz(i) += fiz;
|
|
||||||
|
|
||||||
addStat(stats->total_force_neighs, numneighs);
|
|
||||||
addStat(stats->total_force_iters, (numneighs + VECTOR_WIDTH - 1) / VECTOR_WIDTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
LIKWID_MARKER_STOP("forceLJ-halfneigh");
|
|
||||||
}
|
|
||||||
|
|
||||||
double E = getTimeStamp();
|
|
||||||
return E-S;
|
|
||||||
}
|
|
||||||
|
|
||||||
double computeForceLJFullNeigh_simd(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
|
||||||
int Nlocal = atom->Nlocal;
|
|
||||||
int* neighs;
|
|
||||||
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
|
|
||||||
MD_FLOAT sigma6 = param->sigma6;
|
|
||||||
MD_FLOAT epsilon = param->epsilon;
|
|
||||||
|
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
|
||||||
atom_fx(i) = 0.0;
|
|
||||||
atom_fy(i) = 0.0;
|
|
||||||
atom_fz(i) = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double S = getTimeStamp();
|
|
||||||
|
|
||||||
#ifndef __SIMD_KERNEL__
|
|
||||||
fprintf(stderr, "Error: SIMD kernel not implemented for specified instruction set!");
|
|
||||||
exit(-1);
|
|
||||||
#else
|
|
||||||
MD_SIMD_FLOAT cutforcesq_vec = simd_broadcast(cutforcesq);
|
|
||||||
MD_SIMD_FLOAT sigma6_vec = simd_broadcast(sigma6);
|
|
||||||
MD_SIMD_FLOAT eps_vec = simd_broadcast(epsilon);
|
|
||||||
MD_SIMD_FLOAT c48_vec = simd_broadcast(48.0);
|
|
||||||
MD_SIMD_FLOAT c05_vec = simd_broadcast(0.5);
|
|
||||||
|
|
||||||
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
|
||||||
LIKWID_MARKER_START("force");
|
|
||||||
|
|
||||||
#pragma omp for schedule(runtime)
|
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
|
||||||
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
|
||||||
int numneighs = neighbor->numneigh[i];
|
|
||||||
MD_SIMD_INT numneighs_vec = simd_int_broadcast(numneighs);
|
|
||||||
MD_SIMD_FLOAT xtmp = simd_broadcast(atom_x(i));
|
|
||||||
MD_SIMD_FLOAT ytmp = simd_broadcast(atom_y(i));
|
|
||||||
MD_SIMD_FLOAT ztmp = simd_broadcast(atom_z(i));
|
|
||||||
MD_SIMD_FLOAT fix = simd_zero();
|
|
||||||
MD_SIMD_FLOAT fiy = simd_zero();
|
|
||||||
MD_SIMD_FLOAT fiz = simd_zero();
|
|
||||||
|
|
||||||
for(int k = 0; k < numneighs; k += VECTOR_WIDTH) {
|
|
||||||
// If the last iteration of this loop is separated from the rest, this mask can be set only there
|
|
||||||
MD_SIMD_MASK mask_numneighs = simd_mask_int_cond_lt(simd_int_add(simd_int_broadcast(k), simd_int_seq()), numneighs_vec);
|
|
||||||
MD_SIMD_INT j = simd_int_mask_load(&neighs[k], mask_numneighs);
|
|
||||||
#ifdef AOS
|
|
||||||
MD_SIMD_INT j3 = simd_int_add(simd_int_add(j, j), j); // j * 3
|
|
||||||
MD_SIMD_FLOAT delx = xtmp - simd_gather(j3, &(atom->x[0]), sizeof(MD_FLOAT));
|
|
||||||
MD_SIMD_FLOAT dely = ytmp - simd_gather(j3, &(atom->x[1]), sizeof(MD_FLOAT));
|
|
||||||
MD_SIMD_FLOAT delz = ztmp - simd_gather(j3, &(atom->x[2]), sizeof(MD_FLOAT));
|
|
||||||
#else
|
|
||||||
MD_SIMD_FLOAT delx = xtmp - simd_gather(j, atom->x, sizeof(MD_FLOAT));
|
|
||||||
MD_SIMD_FLOAT dely = ytmp - simd_gather(j, atom->y, sizeof(MD_FLOAT));
|
|
||||||
MD_SIMD_FLOAT delz = ztmp - simd_gather(j, atom->z, sizeof(MD_FLOAT));
|
|
||||||
#endif
|
|
||||||
MD_SIMD_FLOAT rsq = simd_fma(delx, delx, simd_fma(dely, dely, simd_mul(delz, delz)));
|
|
||||||
MD_SIMD_MASK cutoff_mask = simd_mask_and(mask_numneighs, simd_mask_cond_lt(rsq, cutforcesq_vec));
|
|
||||||
MD_SIMD_FLOAT sr2 = simd_reciprocal(rsq);
|
|
||||||
MD_SIMD_FLOAT sr6 = simd_mul(sr2, simd_mul(sr2, simd_mul(sr2, sigma6_vec)));
|
|
||||||
MD_SIMD_FLOAT force = simd_mul(c48_vec, simd_mul(sr6, simd_mul(simd_sub(sr6, c05_vec), simd_mul(sr2, eps_vec))));
|
|
||||||
|
|
||||||
fix = simd_masked_add(fix, simd_mul(delx, force), cutoff_mask);
|
|
||||||
fiy = simd_masked_add(fiy, simd_mul(dely, force), cutoff_mask);
|
|
||||||
fiz = simd_masked_add(fiz, simd_mul(delz, force), cutoff_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
atom_fx(i) += simd_h_reduce_sum(fix);
|
|
||||||
atom_fy(i) += simd_h_reduce_sum(fiy);
|
|
||||||
atom_fz(i) += simd_h_reduce_sum(fiz);
|
|
||||||
}
|
|
||||||
|
|
||||||
LIKWID_MARKER_STOP("force");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
double E = getTimeStamp();
|
|
||||||
return E-S;
|
|
||||||
}
|
|
171
lammps/pbc.c
171
lammps/pbc.c
@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
|
||||||
* license that can be found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
//---
|
|
||||||
#include <pbc.h>
|
|
||||||
#include <atom.h>
|
|
||||||
#include <allocate.h>
|
|
||||||
|
|
||||||
#define DELTA 20000
|
|
||||||
|
|
||||||
int NmaxGhost;
|
|
||||||
int *PBCx, *PBCy, *PBCz;
|
|
||||||
|
|
||||||
static void growPbc(Atom*);
|
|
||||||
|
|
||||||
/* exported subroutines */
|
|
||||||
void initPbc(Atom* atom) {
|
|
||||||
NmaxGhost = 0;
|
|
||||||
atom->border_map = NULL;
|
|
||||||
PBCx = NULL; PBCy = NULL; PBCz = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* update coordinates of ghost atoms */
|
|
||||||
/* uses mapping created in setupPbc */
|
|
||||||
void updatePbc_cpu(Atom *atom, Parameter *param, bool doReneighbor) {
|
|
||||||
int *border_map = atom->border_map;
|
|
||||||
int nlocal = atom->Nlocal;
|
|
||||||
MD_FLOAT xprd = param->xprd;
|
|
||||||
MD_FLOAT yprd = param->yprd;
|
|
||||||
MD_FLOAT zprd = param->zprd;
|
|
||||||
|
|
||||||
for(int i = 0; i < atom->Nghost; i++) {
|
|
||||||
atom_x(nlocal + i) = atom_x(border_map[i]) + PBCx[i] * xprd;
|
|
||||||
atom_y(nlocal + i) = atom_y(border_map[i]) + PBCy[i] * yprd;
|
|
||||||
atom_z(nlocal + i) = atom_z(border_map[i]) + PBCz[i] * zprd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* relocate atoms that have left domain according
|
|
||||||
* to periodic boundary conditions */
|
|
||||||
void updateAtomsPbc_cpu(Atom *atom, Parameter *param) {
|
|
||||||
MD_FLOAT xprd = param->xprd;
|
|
||||||
MD_FLOAT yprd = param->yprd;
|
|
||||||
MD_FLOAT zprd = param->zprd;
|
|
||||||
|
|
||||||
for(int i = 0; i < atom->Nlocal; i++) {
|
|
||||||
if(atom_x(i) < 0.0) {
|
|
||||||
atom_x(i) += xprd;
|
|
||||||
} else if(atom_x(i) >= xprd) {
|
|
||||||
atom_x(i) -= xprd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(atom_y(i) < 0.0) {
|
|
||||||
atom_y(i) += yprd;
|
|
||||||
} else if(atom_y(i) >= yprd) {
|
|
||||||
atom_y(i) -= yprd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(atom_z(i) < 0.0) {
|
|
||||||
atom_z(i) += zprd;
|
|
||||||
} else if(atom_z(i) >= zprd) {
|
|
||||||
atom_z(i) -= zprd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup periodic boundary conditions by
|
|
||||||
* defining ghost atoms around domain
|
|
||||||
* only creates mapping and coordinate corrections
|
|
||||||
* that are then enforced in updatePbc */
|
|
||||||
#define ADDGHOST(dx,dy,dz) \
|
|
||||||
Nghost++; \
|
|
||||||
border_map[Nghost] = i; \
|
|
||||||
PBCx[Nghost] = dx; \
|
|
||||||
PBCy[Nghost] = dy; \
|
|
||||||
PBCz[Nghost] = dz; \
|
|
||||||
atom->type[atom->Nlocal + Nghost] = atom->type[i]
|
|
||||||
|
|
||||||
void setupPbc(Atom *atom, Parameter *param) {
|
|
||||||
int *border_map = atom->border_map;
|
|
||||||
MD_FLOAT xprd = param->xprd;
|
|
||||||
MD_FLOAT yprd = param->yprd;
|
|
||||||
MD_FLOAT zprd = param->zprd;
|
|
||||||
MD_FLOAT Cutneigh = param->cutneigh;
|
|
||||||
int Nghost = -1;
|
|
||||||
|
|
||||||
for(int i = 0; i < atom->Nlocal; i++) {
|
|
||||||
if (atom->Nlocal + Nghost + 7 >= atom->Nmax) {
|
|
||||||
growAtom(atom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Nghost + 7 >= NmaxGhost) {
|
|
||||||
growPbc(atom);
|
|
||||||
border_map = atom->border_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
MD_FLOAT x = atom_x(i);
|
|
||||||
MD_FLOAT y = atom_y(i);
|
|
||||||
MD_FLOAT z = atom_z(i);
|
|
||||||
|
|
||||||
/* Setup ghost atoms */
|
|
||||||
/* 6 planes */
|
|
||||||
if(param->pbc_x != 0) {
|
|
||||||
if (x < Cutneigh) { ADDGHOST(+1,0,0); }
|
|
||||||
if (x >= (xprd-Cutneigh)) { ADDGHOST(-1,0,0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(param->pbc_y != 0) {
|
|
||||||
if (y < Cutneigh) { ADDGHOST(0,+1,0); }
|
|
||||||
if (y >= (yprd-Cutneigh)) { ADDGHOST(0,-1,0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(param->pbc_z != 0) {
|
|
||||||
if (z < Cutneigh) { ADDGHOST(0,0,+1); }
|
|
||||||
if (z >= (zprd-Cutneigh)) { ADDGHOST(0,0,-1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 8 corners */
|
|
||||||
if(param->pbc_x != 0 && param->pbc_y != 0 && param->pbc_z != 0) {
|
|
||||||
if (x < Cutneigh && y < Cutneigh && z < Cutneigh) { ADDGHOST(+1,+1,+1); }
|
|
||||||
if (x < Cutneigh && y >= (yprd-Cutneigh) && z < Cutneigh) { ADDGHOST(+1,-1,+1); }
|
|
||||||
if (x < Cutneigh && y < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(+1,+1,-1); }
|
|
||||||
if (x < Cutneigh && y >= (yprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(+1,-1,-1); }
|
|
||||||
if (x >= (xprd-Cutneigh) && y < Cutneigh && z < Cutneigh) { ADDGHOST(-1,+1,+1); }
|
|
||||||
if (x >= (xprd-Cutneigh) && y >= (yprd-Cutneigh) && z < Cutneigh) { ADDGHOST(-1,-1,+1); }
|
|
||||||
if (x >= (xprd-Cutneigh) && y < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(-1,+1,-1); }
|
|
||||||
if (x >= (xprd-Cutneigh) && y >= (yprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(-1,-1,-1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 12 edges */
|
|
||||||
if(param->pbc_x != 0 && param->pbc_z != 0) {
|
|
||||||
if (x < Cutneigh && z < Cutneigh) { ADDGHOST(+1,0,+1); }
|
|
||||||
if (x < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(+1,0,-1); }
|
|
||||||
if (x >= (xprd-Cutneigh) && z < Cutneigh) { ADDGHOST(-1,0,+1); }
|
|
||||||
if (x >= (xprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(-1,0,-1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(param->pbc_y != 0 && param->pbc_z != 0) {
|
|
||||||
if (y < Cutneigh && z < Cutneigh) { ADDGHOST(0,+1,+1); }
|
|
||||||
if (y < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(0,+1,-1); }
|
|
||||||
if (y >= (yprd-Cutneigh) && z < Cutneigh) { ADDGHOST(0,-1,+1); }
|
|
||||||
if (y >= (yprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(0,-1,-1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(param->pbc_x != 0 && param->pbc_y != 0) {
|
|
||||||
if (y < Cutneigh && x < Cutneigh) { ADDGHOST(+1,+1,0); }
|
|
||||||
if (y < Cutneigh && x >= (xprd-Cutneigh)) { ADDGHOST(-1,+1,0); }
|
|
||||||
if (y >= (yprd-Cutneigh) && x < Cutneigh) { ADDGHOST(+1,-1,0); }
|
|
||||||
if (y >= (yprd-Cutneigh) && x >= (xprd-Cutneigh)) { ADDGHOST(-1,-1,0); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// increase by one to make it the ghost atom count
|
|
||||||
atom->Nghost = Nghost + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* internal subroutines */
|
|
||||||
void growPbc(Atom* atom) {
|
|
||||||
int nold = NmaxGhost;
|
|
||||||
NmaxGhost += DELTA;
|
|
||||||
|
|
||||||
atom->border_map = (int*) reallocate(atom->border_map, ALIGNMENT, NmaxGhost * sizeof(int), nold * sizeof(int));
|
|
||||||
PBCx = (int*) reallocate(PBCx, ALIGNMENT, NmaxGhost * sizeof(int), nold * sizeof(int));
|
|
||||||
PBCy = (int*) reallocate(PBCy, ALIGNMENT, NmaxGhost * sizeof(int), nold * sizeof(int));
|
|
||||||
PBCz = (int*) reallocate(PBCz, ALIGNMENT, NmaxGhost * sizeof(int), nold * sizeof(int));
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2021 RRZE-HPC
|
Copyright (c) RRZE-HPC
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*
|
*
|
||||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
||||||
* Copyright (c) 2021 RRZE, University Erlangen-Nuremberg
|
* Copyright (c) RRZE, University Erlangen-Nuremberg
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*
|
*
|
||||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
||||||
* Copyright (c) 2021 RRZE, University Erlangen-Nuremberg
|
* Copyright (c) RRZE, University Erlangen-Nuremberg
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*
|
*
|
||||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
||||||
* Copyright (c) 2021 RRZE, University Erlangen-Nuremberg
|
* Copyright (c) RRZE, University Erlangen-Nuremberg
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
298
verletlist/force_lj.c
Normal file
298
verletlist/force_lj.c
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
|
* license that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
//---
|
||||||
|
#include <atom.h>
|
||||||
|
#include <likwid-marker.h>
|
||||||
|
#include <neighbor.h>
|
||||||
|
#include <parameter.h>
|
||||||
|
#include <stats.h>
|
||||||
|
#include <timing.h>
|
||||||
|
|
||||||
|
#ifdef __SIMD_KERNEL__
|
||||||
|
#include <simd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
double computeForceLJFullNeigh(
|
||||||
|
Parameter* param, Atom* atom, Neighbor* neighbor, Stats* stats)
|
||||||
|
{
|
||||||
|
int nLocal = atom->Nlocal;
|
||||||
|
int* neighs;
|
||||||
|
#ifndef EXPLICIT_TYPES
|
||||||
|
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
|
||||||
|
MD_FLOAT sigma6 = param->sigma6;
|
||||||
|
MD_FLOAT epsilon = param->epsilon;
|
||||||
|
#endif
|
||||||
|
const MD_FLOAT num1 = 1.0;
|
||||||
|
const MD_FLOAT num48 = 48.0;
|
||||||
|
const MD_FLOAT num05 = 0.5;
|
||||||
|
|
||||||
|
for (int i = 0; i < nLocal; i++) {
|
||||||
|
atom_fx(i) = 0.0;
|
||||||
|
atom_fy(i) = 0.0;
|
||||||
|
atom_fz(i) = 0.0;
|
||||||
|
}
|
||||||
|
double timeStart = getTimeStamp();
|
||||||
|
|
||||||
|
#pragma omp parallel
|
||||||
|
{
|
||||||
|
LIKWID_MARKER_START("force");
|
||||||
|
|
||||||
|
#pragma omp for schedule(runtime)
|
||||||
|
for (int i = 0; i < nLocal; i++) {
|
||||||
|
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
||||||
|
int numneighs = neighbor->numneigh[i];
|
||||||
|
MD_FLOAT xtmp = atom_x(i);
|
||||||
|
MD_FLOAT ytmp = atom_y(i);
|
||||||
|
MD_FLOAT ztmp = atom_z(i);
|
||||||
|
MD_FLOAT fix = 0;
|
||||||
|
MD_FLOAT fiy = 0;
|
||||||
|
MD_FLOAT fiz = 0;
|
||||||
|
|
||||||
|
#ifdef EXPLICIT_TYPES
|
||||||
|
const int type_i = atom->type[i];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int k = 0; k < numneighs; k++) {
|
||||||
|
int j = neighs[k];
|
||||||
|
MD_FLOAT delx = xtmp - atom_x(j);
|
||||||
|
MD_FLOAT dely = ytmp - atom_y(j);
|
||||||
|
MD_FLOAT delz = ztmp - atom_z(j);
|
||||||
|
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
|
||||||
|
|
||||||
|
#ifdef EXPLICIT_TYPES
|
||||||
|
const int type_j = atom->type[j];
|
||||||
|
const int type_ij = type_i * atom->ntypes + type_j;
|
||||||
|
const MD_FLOAT cutforcesq = atom->cutforcesq[type_ij];
|
||||||
|
const MD_FLOAT sigma6 = atom->sigma6[type_ij];
|
||||||
|
const MD_FLOAT epsilon = atom->epsilon[type_ij];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (rsq < cutforcesq) {
|
||||||
|
MD_FLOAT sr2 = num1 / rsq;
|
||||||
|
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
|
||||||
|
MD_FLOAT force = num48 * sr6 * (sr6 - num05) * sr2 * epsilon;
|
||||||
|
fix += delx * force;
|
||||||
|
fiy += dely * force;
|
||||||
|
fiz += delz * force;
|
||||||
|
#ifdef USE_REFERENCE_VERSION
|
||||||
|
addStat(stats->atoms_within_cutoff, 1);
|
||||||
|
} else {
|
||||||
|
addStat(stats->atoms_outside_cutoff, 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
atom_fx(i) += fix;
|
||||||
|
atom_fy(i) += fiy;
|
||||||
|
atom_fz(i) += fiz;
|
||||||
|
|
||||||
|
#ifdef USE_REFERENCE_VERSION
|
||||||
|
if (numneighs % VECTOR_WIDTH > 0) {
|
||||||
|
addStat(stats->atoms_outside_cutoff,
|
||||||
|
VECTOR_WIDTH - (numneighs % VECTOR_WIDTH));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
addStat(stats->total_force_neighs, numneighs);
|
||||||
|
addStat(stats->total_force_iters,
|
||||||
|
(numneighs + VECTOR_WIDTH - 1) / VECTOR_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIKWID_MARKER_STOP("force");
|
||||||
|
}
|
||||||
|
|
||||||
|
double timeStop = getTimeStamp();
|
||||||
|
return timeStop - timeStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
double computeForceLJHalfNeigh(
|
||||||
|
Parameter* param, Atom* atom, Neighbor* neighbor, Stats* stats)
|
||||||
|
{
|
||||||
|
int nlocal = atom->Nlocal;
|
||||||
|
int* neighs;
|
||||||
|
#ifndef EXPLICIT_TYPES
|
||||||
|
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
|
||||||
|
MD_FLOAT sigma6 = param->sigma6;
|
||||||
|
MD_FLOAT epsilon = param->epsilon;
|
||||||
|
#endif
|
||||||
|
const MD_FLOAT num1 = 1.0;
|
||||||
|
const MD_FLOAT num48 = 48.0;
|
||||||
|
const MD_FLOAT num05 = 0.5;
|
||||||
|
|
||||||
|
for (int i = 0; i < nlocal; i++) {
|
||||||
|
atom_fx(i) = 0.0;
|
||||||
|
atom_fy(i) = 0.0;
|
||||||
|
atom_fz(i) = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double timeStart = getTimeStamp();
|
||||||
|
|
||||||
|
#pragma omp parallel
|
||||||
|
{
|
||||||
|
LIKWID_MARKER_START("forceLJ-halfneigh");
|
||||||
|
|
||||||
|
#pragma omp for schedule(runtime)
|
||||||
|
for (int i = 0; i < nlocal; i++) {
|
||||||
|
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
||||||
|
int numneighs = neighbor->numneigh[i];
|
||||||
|
MD_FLOAT xtmp = atom_x(i);
|
||||||
|
MD_FLOAT ytmp = atom_y(i);
|
||||||
|
MD_FLOAT ztmp = atom_z(i);
|
||||||
|
MD_FLOAT fix = 0;
|
||||||
|
MD_FLOAT fiy = 0;
|
||||||
|
MD_FLOAT fiz = 0;
|
||||||
|
|
||||||
|
#ifdef EXPLICIT_TYPES
|
||||||
|
const int type_i = atom->type[i];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Pragma required to vectorize the inner loop
|
||||||
|
#ifdef ENABLE_OMP_SIMD
|
||||||
|
#pragma omp simd reduction(+ : fix, fiy, fiz)
|
||||||
|
#endif
|
||||||
|
for (int k = 0; k < numneighs; k++) {
|
||||||
|
int j = neighs[k];
|
||||||
|
MD_FLOAT delx = xtmp - atom_x(j);
|
||||||
|
MD_FLOAT dely = ytmp - atom_y(j);
|
||||||
|
MD_FLOAT delz = ztmp - atom_z(j);
|
||||||
|
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
|
||||||
|
|
||||||
|
#ifdef EXPLICIT_TYPES
|
||||||
|
const int type_j = atom->type[j];
|
||||||
|
const int type_ij = type_i * atom->ntypes + type_j;
|
||||||
|
const MD_FLOAT cutforcesq = atom->cutforcesq[type_ij];
|
||||||
|
const MD_FLOAT sigma6 = atom->sigma6[type_ij];
|
||||||
|
const MD_FLOAT epsilon = atom->epsilon[type_ij];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (rsq < cutforcesq) {
|
||||||
|
MD_FLOAT sr2 = num1 / rsq;
|
||||||
|
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
|
||||||
|
MD_FLOAT force = num48 * sr6 * (sr6 - num05) * sr2 * epsilon;
|
||||||
|
fix += delx * force;
|
||||||
|
fiy += dely * force;
|
||||||
|
fiz += delz * force;
|
||||||
|
|
||||||
|
// We do not need to update forces for ghost atoms
|
||||||
|
if (j < nlocal) {
|
||||||
|
atom_fx(j) -= delx * force;
|
||||||
|
atom_fy(j) -= dely * force;
|
||||||
|
atom_fz(j) -= delz * force;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
atom_fx(i) += fix;
|
||||||
|
atom_fy(i) += fiy;
|
||||||
|
atom_fz(i) += fiz;
|
||||||
|
|
||||||
|
addStat(stats->total_force_neighs, numneighs);
|
||||||
|
addStat(stats->total_force_iters,
|
||||||
|
(numneighs + VECTOR_WIDTH - 1) / VECTOR_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIKWID_MARKER_STOP("forceLJ-halfneigh");
|
||||||
|
}
|
||||||
|
|
||||||
|
double timeStop = getTimeStamp();
|
||||||
|
return timeStop - timeStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
double computeForceLJFullNeigh_simd(
|
||||||
|
Parameter* param, Atom* atom, Neighbor* neighbor, Stats* stats)
|
||||||
|
{
|
||||||
|
int Nlocal = atom->Nlocal;
|
||||||
|
int* neighs;
|
||||||
|
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
|
||||||
|
MD_FLOAT sigma6 = param->sigma6;
|
||||||
|
MD_FLOAT epsilon = param->epsilon;
|
||||||
|
|
||||||
|
for (int i = 0; i < Nlocal; i++) {
|
||||||
|
atom_fx(i) = 0.0;
|
||||||
|
atom_fy(i) = 0.0;
|
||||||
|
atom_fz(i) = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double S = getTimeStamp();
|
||||||
|
|
||||||
|
#ifndef __SIMD_KERNEL__
|
||||||
|
fprintf(stderr, "Error: SIMD kernel not implemented for specified instruction set!");
|
||||||
|
exit(-1);
|
||||||
|
#else
|
||||||
|
MD_SIMD_FLOAT cutforcesq_vec = simd_broadcast(cutforcesq);
|
||||||
|
MD_SIMD_FLOAT sigma6_vec = simd_broadcast(sigma6);
|
||||||
|
MD_SIMD_FLOAT eps_vec = simd_broadcast(epsilon);
|
||||||
|
MD_SIMD_FLOAT c48_vec = simd_broadcast(48.0);
|
||||||
|
MD_SIMD_FLOAT c05_vec = simd_broadcast(0.5);
|
||||||
|
|
||||||
|
#pragma omp parallel
|
||||||
|
{
|
||||||
|
LIKWID_MARKER_START("force");
|
||||||
|
|
||||||
|
#pragma omp for schedule(runtime)
|
||||||
|
for (int i = 0; i < Nlocal; i++) {
|
||||||
|
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
||||||
|
int numneighs = neighbor->numneigh[i];
|
||||||
|
MD_SIMD_INT numneighs_vec = simd_int_broadcast(numneighs);
|
||||||
|
MD_SIMD_FLOAT xtmp = simd_broadcast(atom_x(i));
|
||||||
|
MD_SIMD_FLOAT ytmp = simd_broadcast(atom_y(i));
|
||||||
|
MD_SIMD_FLOAT ztmp = simd_broadcast(atom_z(i));
|
||||||
|
MD_SIMD_FLOAT fix = simd_zero();
|
||||||
|
MD_SIMD_FLOAT fiy = simd_zero();
|
||||||
|
MD_SIMD_FLOAT fiz = simd_zero();
|
||||||
|
|
||||||
|
for (int k = 0; k < numneighs; k += VECTOR_WIDTH) {
|
||||||
|
// If the last iteration of this loop is separated from the rest, this
|
||||||
|
// mask can be set only there
|
||||||
|
MD_SIMD_MASK mask_numneighs = simd_mask_int_cond_lt(
|
||||||
|
simd_int_add(simd_int_broadcast(k), simd_int_seq()),
|
||||||
|
numneighs_vec);
|
||||||
|
MD_SIMD_INT j = simd_int_mask_load(&neighs[k], mask_numneighs);
|
||||||
|
#ifdef AOS
|
||||||
|
MD_SIMD_INT j3 = simd_int_add(simd_int_add(j, j), j); // j * 3
|
||||||
|
MD_SIMD_FLOAT delx = xtmp -
|
||||||
|
simd_gather(j3, &(atom->x[0]), sizeof(MD_FLOAT));
|
||||||
|
MD_SIMD_FLOAT dely = ytmp -
|
||||||
|
simd_gather(j3, &(atom->x[1]), sizeof(MD_FLOAT));
|
||||||
|
MD_SIMD_FLOAT delz = ztmp -
|
||||||
|
simd_gather(j3, &(atom->x[2]), sizeof(MD_FLOAT));
|
||||||
|
#else
|
||||||
|
MD_SIMD_FLOAT delx = xtmp - simd_gather(j, atom->x, sizeof(MD_FLOAT));
|
||||||
|
MD_SIMD_FLOAT dely = ytmp - simd_gather(j, atom->y, sizeof(MD_FLOAT));
|
||||||
|
MD_SIMD_FLOAT delz = ztmp - simd_gather(j, atom->z, sizeof(MD_FLOAT));
|
||||||
|
#endif
|
||||||
|
MD_SIMD_FLOAT rsq = simd_fma(delx,
|
||||||
|
delx,
|
||||||
|
simd_fma(dely, dely, simd_mul(delz, delz)));
|
||||||
|
MD_SIMD_MASK cutoff_mask = simd_mask_and(mask_numneighs,
|
||||||
|
simd_mask_cond_lt(rsq, cutforcesq_vec));
|
||||||
|
MD_SIMD_FLOAT sr2 = simd_reciprocal(rsq);
|
||||||
|
MD_SIMD_FLOAT sr6 = simd_mul(sr2,
|
||||||
|
simd_mul(sr2, simd_mul(sr2, sigma6_vec)));
|
||||||
|
MD_SIMD_FLOAT force = simd_mul(c48_vec,
|
||||||
|
simd_mul(sr6,
|
||||||
|
simd_mul(simd_sub(sr6, c05_vec), simd_mul(sr2, eps_vec))));
|
||||||
|
|
||||||
|
fix = simd_masked_add(fix, simd_mul(delx, force), cutoff_mask);
|
||||||
|
fiy = simd_masked_add(fiy, simd_mul(dely, force), cutoff_mask);
|
||||||
|
fiz = simd_masked_add(fiz, simd_mul(delz, force), cutoff_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
atom_fx(i) += simd_h_reduce_sum(fix);
|
||||||
|
atom_fy(i) += simd_h_reduce_sum(fiy);
|
||||||
|
atom_fz(i) += simd_h_reduce_sum(fiz);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIKWID_MARKER_STOP("force");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
double E = getTimeStamp();
|
||||||
|
return E - S;
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#ifndef __PBC_H_
|
#ifndef __PBC_H_
|
||||||
#define __PBC_H_
|
#define __PBC_H_
|
||||||
extern void initPbc();
|
extern void initPbc(Atom*);
|
||||||
extern void updatePbc_cpu(Atom*, Parameter*, bool);
|
extern void updatePbc_cpu(Atom*, Parameter*, bool);
|
||||||
extern void updateAtomsPbc_cpu(Atom*, Parameter*);
|
extern void updateAtomsPbc_cpu(Atom*, Parameter*);
|
||||||
extern void setupPbc(Atom*, Parameter*);
|
extern void setupPbc(Atom*, Parameter*);
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,18 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <omp.h>
|
|
||||||
|
|
||||||
|
// #include <omp.h>
|
||||||
#include <likwid-marker.h>
|
#include <likwid-marker.h>
|
||||||
|
|
||||||
#include <allocate.h>
|
#include <allocate.h>
|
||||||
@ -20,20 +18,19 @@
|
|||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <eam.h>
|
#include <eam.h>
|
||||||
#include <integrate.h>
|
#include <integrate.h>
|
||||||
#include <thermo.h>
|
|
||||||
#include <timing.h>
|
|
||||||
#include <neighbor.h>
|
#include <neighbor.h>
|
||||||
#include <parameter.h>
|
#include <parameter.h>
|
||||||
#include <pbc.h>
|
#include <pbc.h>
|
||||||
#include <stats.h>
|
#include <stats.h>
|
||||||
|
#include <thermo.h>
|
||||||
#include <timers.h>
|
#include <timers.h>
|
||||||
|
#include <timing.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <vtk.h>
|
#include <vtk.h>
|
||||||
|
|
||||||
#define HLINE "----------------------------------------------------------------------------\n"
|
#define HLINE "------------------------------------------------------------------\n"
|
||||||
|
|
||||||
extern double computeForceLJFullNeigh_plain_c(Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceLJFullNeigh_plain_c(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
extern double computeForceLJFullNeigh_simd(Parameter*, Atom*, Neighbor*, Stats*);
|
|
||||||
extern double computeForceLJHalfNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceLJHalfNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
extern double computeForceEam(Eam*, Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceEam(Eam*, Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
extern double computeForceDemFullNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceDemFullNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
@ -42,20 +39,23 @@ extern double computeForceDemFullNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
|||||||
extern double computeForceLJFullNeigh_cuda(Parameter*, Atom*, Neighbor*);
|
extern double computeForceLJFullNeigh_cuda(Parameter*, Atom*, Neighbor*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
double setup(Parameter *param, Eam *eam, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
double setup(Parameter* param, Eam* eam, Atom* atom, Neighbor* neighbor, Stats* stats)
|
||||||
if(param->force_field == FF_EAM) { initEam(eam, param); }
|
{
|
||||||
double S, E;
|
if (param->force_field == FF_EAM) {
|
||||||
|
initEam(eam, param);
|
||||||
|
}
|
||||||
|
double timeStart, timeStop;
|
||||||
param->lattice = pow((4.0 / param->rho), (1.0 / 3.0));
|
param->lattice = pow((4.0 / param->rho), (1.0 / 3.0));
|
||||||
param->xprd = param->nx * param->lattice;
|
param->xprd = param->nx * param->lattice;
|
||||||
param->yprd = param->ny * param->lattice;
|
param->yprd = param->ny * param->lattice;
|
||||||
param->zprd = param->nz * param->lattice;
|
param->zprd = param->nz * param->lattice;
|
||||||
|
|
||||||
S = getTimeStamp();
|
timeStart = getTimeStamp();
|
||||||
initAtom(atom);
|
initAtom(atom);
|
||||||
initPbc(atom);
|
initPbc(atom);
|
||||||
initStats(stats);
|
initStats(stats);
|
||||||
initNeighbor(neighbor, param);
|
initNeighbor(neighbor, param);
|
||||||
if(param->input_file == NULL) {
|
if (param->input_file == NULL) {
|
||||||
createAtom(atom, param);
|
createAtom(atom, param);
|
||||||
} else {
|
} else {
|
||||||
readAtom(atom, param);
|
readAtom(atom, param);
|
||||||
@ -63,49 +63,59 @@ double setup(Parameter *param, Eam *eam, Atom *atom, Neighbor *neighbor, Stats *
|
|||||||
|
|
||||||
setupNeighbor(param);
|
setupNeighbor(param);
|
||||||
setupThermo(param, atom->Natoms);
|
setupThermo(param, atom->Natoms);
|
||||||
if(param->input_file == NULL) { adjustThermo(param, atom); }
|
if (param->input_file == NULL) {
|
||||||
#ifdef SORT_ATOMS
|
adjustThermo(param, atom);
|
||||||
|
}
|
||||||
|
#ifdef SORT_ATOMS
|
||||||
atom->Nghost = 0;
|
atom->Nghost = 0;
|
||||||
sortAtom(atom);
|
sortAtom(atom);
|
||||||
#endif
|
#endif
|
||||||
setupPbc(atom, param);
|
setupPbc(atom, param);
|
||||||
initDevice(atom, neighbor);
|
initDevice(atom, neighbor);
|
||||||
updatePbc(atom, param, true);
|
updatePbc(atom, param, true);
|
||||||
buildNeighbor(atom, neighbor);
|
buildNeighbor(atom, neighbor);
|
||||||
E = getTimeStamp();
|
timeStop = getTimeStamp();
|
||||||
return E-S;
|
return timeStop - timeStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
double reneighbour(Parameter *param, Atom *atom, Neighbor *neighbor) {
|
double reneighbour(Parameter* param, Atom* atom, Neighbor* neighbor)
|
||||||
double S, E;
|
{
|
||||||
S = getTimeStamp();
|
double timeStart, timeStop;
|
||||||
|
timeStart = getTimeStamp();
|
||||||
LIKWID_MARKER_START("reneighbour");
|
LIKWID_MARKER_START("reneighbour");
|
||||||
updateAtomsPbc(atom, param);
|
updateAtomsPbc(atom, param);
|
||||||
#ifdef SORT_ATOMS
|
#ifdef SORT_ATOMS
|
||||||
atom->Nghost = 0;
|
atom->Nghost = 0;
|
||||||
sortAtom(atom);
|
sortAtom(atom);
|
||||||
#endif
|
#endif
|
||||||
setupPbc(atom, param);
|
setupPbc(atom, param);
|
||||||
updatePbc(atom, param, true);
|
updatePbc(atom, param, true);
|
||||||
buildNeighbor(atom, neighbor);
|
buildNeighbor(atom, neighbor);
|
||||||
LIKWID_MARKER_STOP("reneighbour");
|
LIKWID_MARKER_STOP("reneighbour");
|
||||||
E = getTimeStamp();
|
timeStop = getTimeStamp();
|
||||||
return E-S;
|
return timeStop - timeStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printAtomState(Atom *atom) {
|
void printAtomState(Atom* atom)
|
||||||
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n", atom->Natoms, atom->Nlocal, atom->Nghost, atom->Nmax);
|
{
|
||||||
|
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n",
|
||||||
|
atom->Natoms,
|
||||||
|
atom->Nlocal,
|
||||||
|
atom->Nghost,
|
||||||
|
atom->Nmax);
|
||||||
// int nall = atom->Nlocal + atom->Nghost;
|
// int nall = atom->Nlocal + atom->Nghost;
|
||||||
// for (int i=0; i<nall; i++) {
|
// for (int i=0; i<nall; i++) {
|
||||||
// printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]);
|
// printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
double computeForce(Eam *eam, Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
double computeForce(
|
||||||
if(param->force_field == FF_EAM) {
|
Eam* eam, Parameter* param, Atom* atom, Neighbor* neighbor, Stats* stats)
|
||||||
|
{
|
||||||
|
if (param->force_field == FF_EAM) {
|
||||||
return computeForceEam(eam, param, atom, neighbor, stats);
|
return computeForceEam(eam, param, atom, neighbor, stats);
|
||||||
} else if(param->force_field == FF_DEM) {
|
} else if (param->force_field == FF_DEM) {
|
||||||
if(param->half_neigh) {
|
if (param->half_neigh) {
|
||||||
fprintf(stderr, "Error: DEM cannot use half neighbor-lists!\n");
|
fprintf(stderr, "Error: DEM cannot use half neighbor-lists!\n");
|
||||||
return 0.0;
|
return 0.0;
|
||||||
} else {
|
} else {
|
||||||
@ -113,29 +123,38 @@ double computeForce(Eam *eam, Parameter *param, Atom *atom, Neighbor *neighbor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param->half_neigh) {
|
if (param->half_neigh) {
|
||||||
return computeForceLJHalfNeigh(param, atom, neighbor, stats);
|
return computeForceLJHalfNeigh(param, atom, neighbor, stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CUDA_TARGET
|
#ifdef CUDA_TARGET
|
||||||
return computeForceLJFullNeigh(param, atom, neighbor);
|
return computeForceLJFullNeigh(param, atom, neighbor);
|
||||||
#else
|
#else
|
||||||
return computeForceLJFullNeigh(param, atom, neighbor, stats);
|
return computeForceLJFullNeigh(param, atom, neighbor, stats);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeInput(Parameter *param, Atom *atom) {
|
void writeInput(Parameter* param, Atom* atom)
|
||||||
FILE *fpin = fopen("input.in", "w");
|
{
|
||||||
|
FILE* fpin = fopen("input.in", "w");
|
||||||
fprintf(fpin, "0,%f,0,%f,0,%f\n", param->xprd, param->yprd, param->zprd);
|
fprintf(fpin, "0,%f,0,%f,0,%f\n", param->xprd, param->yprd, param->zprd);
|
||||||
|
|
||||||
for(int i = 0; i < atom->Nlocal; i++) {
|
for (int i = 0; i < atom->Nlocal; i++) {
|
||||||
fprintf(fpin, "1,%f,%f,%f,%f,%f,%f\n", atom_x(i), atom_y(i), atom_z(i), atom_vx(i), atom_vy(i), atom_vz(i));
|
fprintf(fpin,
|
||||||
|
"1,%f,%f,%f,%f,%f,%f\n",
|
||||||
|
atom_x(i),
|
||||||
|
atom_y(i),
|
||||||
|
atom_z(i),
|
||||||
|
atom_vx(i),
|
||||||
|
atom_vy(i),
|
||||||
|
atom_vz(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
double timer[NUMTIMER];
|
double timer[NUMTIMER];
|
||||||
Eam eam;
|
Eam eam;
|
||||||
Atom atom;
|
Atom atom;
|
||||||
@ -147,81 +166,87 @@ int main(int argc, char** argv) {
|
|||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
LIKWID_MARKER_REGISTER("force");
|
LIKWID_MARKER_REGISTER("force");
|
||||||
//LIKWID_MARKER_REGISTER("reneighbour");
|
// LIKWID_MARKER_REGISTER("reneighbour");
|
||||||
//LIKWID_MARKER_REGISTER("pbc");
|
// LIKWID_MARKER_REGISTER("pbc");
|
||||||
}
|
}
|
||||||
|
|
||||||
initParameter(¶m);
|
initParameter(¶m);
|
||||||
for(int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
if((strcmp(argv[i], "-p") == 0) || strcmp(argv[i], "--params") == 0) {
|
if ((strcmp(argv[i], "-p") == 0) || strcmp(argv[i], "--params") == 0) {
|
||||||
readParameter(¶m, argv[++i]);
|
readParameter(¶m, argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-f") == 0)) {
|
if ((strcmp(argv[i], "-f") == 0)) {
|
||||||
if((param.force_field = str2ff(argv[++i])) < 0) {
|
if ((param.force_field = str2ff(argv[++i])) < 0) {
|
||||||
fprintf(stderr, "Invalid force field!\n");
|
fprintf(stderr, "Invalid force field!\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-i") == 0)) {
|
if ((strcmp(argv[i], "-i") == 0)) {
|
||||||
param.input_file = strdup(argv[++i]);
|
param.input_file = strdup(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-e") == 0)) {
|
if ((strcmp(argv[i], "-e") == 0)) {
|
||||||
param.eam_file = strdup(argv[++i]);
|
param.eam_file = strdup(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) {
|
if ((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) {
|
||||||
param.ntimes = atoi(argv[++i]);
|
param.ntimes = atoi(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-nx") == 0)) {
|
if ((strcmp(argv[i], "-nx") == 0)) {
|
||||||
param.nx = atoi(argv[++i]);
|
param.nx = atoi(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-ny") == 0)) {
|
if ((strcmp(argv[i], "-ny") == 0)) {
|
||||||
param.ny = atoi(argv[++i]);
|
param.ny = atoi(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-nz") == 0)) {
|
if ((strcmp(argv[i], "-nz") == 0)) {
|
||||||
param.nz = atoi(argv[++i]);
|
param.nz = atoi(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-half") == 0)) {
|
if ((strcmp(argv[i], "-half") == 0)) {
|
||||||
param.half_neigh = atoi(argv[++i]);
|
param.half_neigh = atoi(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-r") == 0) || (strcmp(argv[i], "--radius") == 0)) {
|
if ((strcmp(argv[i], "-r") == 0) || (strcmp(argv[i], "--radius") == 0)) {
|
||||||
param.cutforce = atof(argv[++i]);
|
param.cutforce = atof(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-s") == 0) || (strcmp(argv[i], "--skin") == 0)) {
|
if ((strcmp(argv[i], "-s") == 0) || (strcmp(argv[i], "--skin") == 0)) {
|
||||||
param.skin = atof(argv[++i]);
|
param.skin = atof(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "--freq") == 0)) {
|
if ((strcmp(argv[i], "--freq") == 0)) {
|
||||||
param.proc_freq = atof(argv[++i]);
|
param.proc_freq = atof(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "--vtk") == 0)) {
|
if ((strcmp(argv[i], "--vtk") == 0)) {
|
||||||
param.vtk_file = strdup(argv[++i]);
|
param.vtk_file = strdup(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-w") == 0)) {
|
if ((strcmp(argv[i], "-w") == 0)) {
|
||||||
param.write_atom_file = strdup(argv[++i]);
|
param.write_atom_file = strdup(argv[++i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
|
if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
|
||||||
printf("MD Bench: A minimalistic re-implementation of miniMD\n");
|
printf("MD Bench: A minimalistic re-implementation of miniMD\n");
|
||||||
printf(HLINE);
|
printf(HLINE);
|
||||||
printf("-p / --params <string>: file to read parameters from (can be specified more than once)\n");
|
printf("-p / --params <string>: file to read parameters from (can be "
|
||||||
printf("-f <string>: force field (lj, eam or dem), default lj\n");
|
"specified more than once)\n");
|
||||||
printf("-i <string>: input file with atom positions (dump)\n");
|
printf("-f <string>: force field (lj, eam or dem), "
|
||||||
|
"default lj\n");
|
||||||
|
printf("-i <string>: input file with atom positions "
|
||||||
|
"(dump)\n");
|
||||||
printf("-e <string>: input file for EAM\n");
|
printf("-e <string>: input file for EAM\n");
|
||||||
printf("-n / --nsteps <int>: set number of timesteps for simulation\n");
|
printf("-n / --nsteps <int>: set number of timesteps for "
|
||||||
printf("-nx/-ny/-nz <int>: set linear dimension of systembox in x/y/z direction\n");
|
"simulation\n");
|
||||||
printf("-half <int>: use half (1) or full (0) neighbor lists\n");
|
printf("-nx/-ny/-nz <int>: set linear dimension of systembox in "
|
||||||
|
"x/y/z direction\n");
|
||||||
|
printf("-half <int>: use half (1) or full (0) neighbor "
|
||||||
|
"lists\n");
|
||||||
printf("-r / --radius <real>: set cutoff radius\n");
|
printf("-r / --radius <real>: set cutoff radius\n");
|
||||||
printf("-s / --skin <real>: set skin (verlet buffer)\n");
|
printf("-s / --skin <real>: set skin (verlet buffer)\n");
|
||||||
printf("-w <file>: write input atoms to file\n");
|
printf("-w <file>: write input atoms to file\n");
|
||||||
@ -239,48 +264,48 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
printf("step\ttemp\t\tpressure\n");
|
printf("step\ttemp\t\tpressure\n");
|
||||||
computeThermo(0, ¶m, &atom);
|
computeThermo(0, ¶m, &atom);
|
||||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER)
|
#if defined(MEM_TRACER) || defined(INDEX_TRACER)
|
||||||
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(param.write_atom_file != NULL) {
|
if (param.write_atom_file != NULL) {
|
||||||
writeAtom(&atom, ¶m);
|
writeAtom(&atom, ¶m);
|
||||||
}
|
}
|
||||||
|
|
||||||
//writeInput(¶m, &atom);
|
// writeInput(¶m, &atom);
|
||||||
|
|
||||||
timer[FORCE] = computeForce(&eam, ¶m, &atom, &neighbor, &stats);
|
timer[FORCE] = computeForce(&eam, ¶m, &atom, &neighbor, &stats);
|
||||||
timer[NEIGH] = 0.0;
|
timer[NEIGH] = 0.0;
|
||||||
timer[TOTAL] = getTimeStamp();
|
timer[TOTAL] = getTimeStamp();
|
||||||
|
|
||||||
if(param.vtk_file != NULL) {
|
if (param.vtk_file != NULL) {
|
||||||
write_atoms_to_vtk_file(param.vtk_file, &atom, 0);
|
write_atoms_to_vtk_file(param.vtk_file, &atom, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int n = 0; n < param.ntimes; n++) {
|
for (int n = 0; n < param.ntimes; n++) {
|
||||||
bool reneigh = (n + 1) % param.reneigh_every == 0;
|
bool reneigh = (n + 1) % param.reneigh_every == 0;
|
||||||
initialIntegrate(reneigh, ¶m, &atom);
|
initialIntegrate(reneigh, ¶m, &atom);
|
||||||
if((n + 1) % param.reneigh_every) {
|
if ((n + 1) % param.reneigh_every) {
|
||||||
updatePbc(&atom, ¶m, false);
|
updatePbc(&atom, ¶m, false);
|
||||||
} else {
|
} else {
|
||||||
timer[NEIGH] += reneighbour(¶m, &atom, &neighbor);
|
timer[NEIGH] += reneighbour(¶m, &atom, &neighbor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER)
|
#if defined(MEM_TRACER) || defined(INDEX_TRACER)
|
||||||
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timer[FORCE] += computeForce(&eam, ¶m, &atom, &neighbor, &stats);
|
timer[FORCE] += computeForce(&eam, ¶m, &atom, &neighbor, &stats);
|
||||||
finalIntegrate(reneigh, ¶m, &atom);
|
finalIntegrate(reneigh, ¶m, &atom);
|
||||||
|
|
||||||
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
if (!((n + 1) % param.nstat) && (n + 1) < param.ntimes) {
|
||||||
#ifdef CUDA_TARGET
|
#ifdef CUDA_TARGET
|
||||||
memcpyFromGPU(atom.x, atom.d_atom.x, atom.Nmax * sizeof(MD_FLOAT) * 3);
|
memcpyFromGPU(atom.x, atom.d_atom.x, atom.Nmax * sizeof(MD_FLOAT) * 3);
|
||||||
#endif
|
#endif
|
||||||
computeThermo(n + 1, ¶m, &atom);
|
computeThermo(n + 1, ¶m, &atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param.vtk_file != NULL) {
|
if (param.vtk_file != NULL) {
|
||||||
write_atoms_to_vtk_file(param.vtk_file, &atom, n + 1);
|
write_atoms_to_vtk_file(param.vtk_file, &atom, n + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,36 +314,49 @@ int main(int argc, char** argv) {
|
|||||||
computeThermo(-1, ¶m, &atom);
|
computeThermo(-1, ¶m, &atom);
|
||||||
|
|
||||||
printf(HLINE);
|
printf(HLINE);
|
||||||
printf("System: %d atoms %d ghost atoms, Steps: %d\n", atom.Natoms, atom.Nghost, param.ntimes);
|
printf("System: %d atoms %d ghost atoms, Steps: %d\n",
|
||||||
|
atom.Natoms,
|
||||||
|
atom.Nghost,
|
||||||
|
param.ntimes);
|
||||||
printf("TOTAL %.2fs FORCE %.2fs NEIGH %.2fs REST %.2fs\n",
|
printf("TOTAL %.2fs FORCE %.2fs NEIGH %.2fs REST %.2fs\n",
|
||||||
timer[TOTAL], timer[FORCE], timer[NEIGH], timer[TOTAL]-timer[FORCE]-timer[NEIGH]);
|
timer[TOTAL],
|
||||||
|
timer[FORCE],
|
||||||
|
timer[NEIGH],
|
||||||
|
timer[TOTAL] - timer[FORCE] - timer[NEIGH]);
|
||||||
printf(HLINE);
|
printf(HLINE);
|
||||||
|
|
||||||
int nthreads = 0;
|
// int nthreads = 0;
|
||||||
int chunkSize = 0;
|
// int chunkSize = 0;
|
||||||
omp_sched_t schedKind;
|
// omp_sched_t schedKind;
|
||||||
char schedType[10];
|
// char schedType[10];
|
||||||
#pragma omp parallel
|
// #pragma omp parallel
|
||||||
#pragma omp master
|
// #pragma omp master
|
||||||
{
|
// {
|
||||||
omp_get_schedule(&schedKind, &chunkSize);
|
// omp_get_schedule(&schedKind, &chunkSize);
|
||||||
|
//
|
||||||
|
// switch (schedKind) {
|
||||||
|
// case omp_sched_static:
|
||||||
|
// strcpy(schedType, "static");
|
||||||
|
// break;
|
||||||
|
// case omp_sched_dynamic:
|
||||||
|
// strcpy(schedType, "dynamic");
|
||||||
|
// break;
|
||||||
|
// case omp_sched_guided:
|
||||||
|
// strcpy(schedType, "guided");
|
||||||
|
// break;
|
||||||
|
// case omp_sched_auto:
|
||||||
|
// strcpy(schedType, "auto");
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// nthreads = omp_get_max_threads();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// printf("Num threads: %d\n", nthreads);
|
||||||
|
// printf("Schedule: (%s,%d)\n", schedType, chunkSize);
|
||||||
|
|
||||||
switch (schedKind)
|
|
||||||
{
|
|
||||||
case omp_sched_static: strcpy(schedType, "static"); break;
|
|
||||||
case omp_sched_dynamic: strcpy(schedType, "dynamic"); break;
|
|
||||||
case omp_sched_guided: strcpy(schedType, "guided"); break;
|
|
||||||
case omp_sched_auto: strcpy(schedType, "auto"); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nthreads = omp_get_max_threads();
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Num threads: %d\n", nthreads);
|
|
||||||
printf("Schedule: (%s,%d)\n", schedType, chunkSize);
|
|
||||||
|
|
||||||
printf("Performance: %.2f million atom updates per second\n",
|
printf("Performance: %.2f million atom updates per second\n",
|
||||||
1e-6 * (double) atom.Natoms * param.ntimes / timer[TOTAL]);
|
1e-6 * (double)atom.Natoms * param.ntimes / timer[TOTAL]);
|
||||||
#ifdef COMPUTE_STATS
|
#ifdef COMPUTE_STATS
|
||||||
displayStatistics(&atom, ¶m, &stats, timer);
|
displayStatistics(&atom, ¶m, &stats, timer);
|
||||||
#endif
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
234
verletlist/pbc.c
Normal file
234
verletlist/pbc.c
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
|
* license that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
//---
|
||||||
|
#include <allocate.h>
|
||||||
|
#include <atom.h>
|
||||||
|
#include <pbc.h>
|
||||||
|
|
||||||
|
#define DELTA 20000
|
||||||
|
|
||||||
|
int nmaxGhost;
|
||||||
|
int *PBCx, *PBCy, *PBCz;
|
||||||
|
|
||||||
|
static void growPbc(Atom*);
|
||||||
|
|
||||||
|
/* exported subroutines */
|
||||||
|
void initPbc(Atom* atom)
|
||||||
|
{
|
||||||
|
nmaxGhost = 0;
|
||||||
|
atom->border_map = NULL;
|
||||||
|
PBCx = NULL;
|
||||||
|
PBCy = NULL;
|
||||||
|
PBCz = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update coordinates of ghost atoms */
|
||||||
|
/* uses mapping created in setupPbc */
|
||||||
|
void updatePbc_cpu(Atom* atom, Parameter* param, bool doReneighbor)
|
||||||
|
{
|
||||||
|
int* borderMap = atom->border_map;
|
||||||
|
int nlocal = atom->Nlocal;
|
||||||
|
MD_FLOAT xprd = param->xprd;
|
||||||
|
MD_FLOAT yprd = param->yprd;
|
||||||
|
MD_FLOAT zprd = param->zprd;
|
||||||
|
|
||||||
|
for (int i = 0; i < atom->Nghost; i++) {
|
||||||
|
atom_x(nlocal + i) = atom_x(borderMap[i]) + PBCx[i] * xprd;
|
||||||
|
atom_y(nlocal + i) = atom_y(borderMap[i]) + PBCy[i] * yprd;
|
||||||
|
atom_z(nlocal + i) = atom_z(borderMap[i]) + PBCz[i] * zprd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* relocate atoms that have left domain according
|
||||||
|
* to periodic boundary conditions */
|
||||||
|
void updateAtomsPbc_cpu(Atom* atom, Parameter* param)
|
||||||
|
{
|
||||||
|
MD_FLOAT xprd = param->xprd;
|
||||||
|
MD_FLOAT yprd = param->yprd;
|
||||||
|
MD_FLOAT zprd = param->zprd;
|
||||||
|
|
||||||
|
for (int i = 0; i < atom->Nlocal; i++) {
|
||||||
|
if (atom_x(i) < 0.0) {
|
||||||
|
atom_x(i) += xprd;
|
||||||
|
} else if (atom_x(i) >= xprd) {
|
||||||
|
atom_x(i) -= xprd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atom_y(i) < 0.0) {
|
||||||
|
atom_y(i) += yprd;
|
||||||
|
} else if (atom_y(i) >= yprd) {
|
||||||
|
atom_y(i) -= yprd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atom_z(i) < 0.0) {
|
||||||
|
atom_z(i) += zprd;
|
||||||
|
} else if (atom_z(i) >= zprd) {
|
||||||
|
atom_z(i) -= zprd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* setup periodic boundary conditions by
|
||||||
|
* defining ghost atoms around domain
|
||||||
|
* only creates mapping and coordinate corrections
|
||||||
|
* that are then enforced in updatePbc */
|
||||||
|
#define ADDGHOST(dx, dy, dz) \
|
||||||
|
Nghost++; \
|
||||||
|
border_map[Nghost] = i; \
|
||||||
|
PBCx[Nghost] = dx; \
|
||||||
|
PBCy[Nghost] = dy; \
|
||||||
|
PBCz[Nghost] = dz; \
|
||||||
|
atom->type[atom->Nlocal + Nghost] = atom->type[i]
|
||||||
|
|
||||||
|
void setupPbc(Atom* atom, Parameter* param)
|
||||||
|
{
|
||||||
|
int* border_map = atom->border_map;
|
||||||
|
MD_FLOAT xprd = param->xprd;
|
||||||
|
MD_FLOAT yprd = param->yprd;
|
||||||
|
MD_FLOAT zprd = param->zprd;
|
||||||
|
MD_FLOAT cutneigh = param->cutneigh;
|
||||||
|
int Nghost = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < atom->Nlocal; i++) {
|
||||||
|
if (atom->Nlocal + Nghost + 7 >= atom->Nmax) {
|
||||||
|
growAtom(atom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Nghost + 7 >= nmaxGhost) {
|
||||||
|
growPbc(atom);
|
||||||
|
border_map = atom->border_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
MD_FLOAT x = atom_x(i);
|
||||||
|
MD_FLOAT y = atom_y(i);
|
||||||
|
MD_FLOAT z = atom_z(i);
|
||||||
|
|
||||||
|
/* Setup ghost atoms */
|
||||||
|
/* 6 planes */
|
||||||
|
if (param->pbc_x != 0) {
|
||||||
|
if (x < cutneigh) {
|
||||||
|
ADDGHOST(+1, 0, 0);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh)) {
|
||||||
|
ADDGHOST(-1, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->pbc_y != 0) {
|
||||||
|
if (y < cutneigh) {
|
||||||
|
ADDGHOST(0, +1, 0);
|
||||||
|
}
|
||||||
|
if (y >= (yprd - cutneigh)) {
|
||||||
|
ADDGHOST(0, -1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->pbc_z != 0) {
|
||||||
|
if (z < cutneigh) {
|
||||||
|
ADDGHOST(0, 0, +1);
|
||||||
|
}
|
||||||
|
if (z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(0, 0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 8 corners */
|
||||||
|
if (param->pbc_x != 0 && param->pbc_y != 0 && param->pbc_z != 0) {
|
||||||
|
if (x < cutneigh && y < cutneigh && z < cutneigh) {
|
||||||
|
ADDGHOST(+1, +1, +1);
|
||||||
|
}
|
||||||
|
if (x < cutneigh && y >= (yprd - cutneigh) && z < cutneigh) {
|
||||||
|
ADDGHOST(+1, -1, +1);
|
||||||
|
}
|
||||||
|
if (x < cutneigh && y < cutneigh && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(+1, +1, -1);
|
||||||
|
}
|
||||||
|
if (x < cutneigh && y >= (yprd - cutneigh) && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(+1, -1, -1);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh) && y < cutneigh && z < cutneigh) {
|
||||||
|
ADDGHOST(-1, +1, +1);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh) && y >= (yprd - cutneigh) && z < cutneigh) {
|
||||||
|
ADDGHOST(-1, -1, +1);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh) && y < cutneigh && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(-1, +1, -1);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh) && y >= (yprd - cutneigh) &&
|
||||||
|
z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(-1, -1, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 12 edges */
|
||||||
|
if (param->pbc_x != 0 && param->pbc_z != 0) {
|
||||||
|
if (x < cutneigh && z < cutneigh) {
|
||||||
|
ADDGHOST(+1, 0, +1);
|
||||||
|
}
|
||||||
|
if (x < cutneigh && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(+1, 0, -1);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh) && z < cutneigh) {
|
||||||
|
ADDGHOST(-1, 0, +1);
|
||||||
|
}
|
||||||
|
if (x >= (xprd - cutneigh) && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(-1, 0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->pbc_y != 0 && param->pbc_z != 0) {
|
||||||
|
if (y < cutneigh && z < cutneigh) {
|
||||||
|
ADDGHOST(0, +1, +1);
|
||||||
|
}
|
||||||
|
if (y < cutneigh && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(0, +1, -1);
|
||||||
|
}
|
||||||
|
if (y >= (yprd - cutneigh) && z < cutneigh) {
|
||||||
|
ADDGHOST(0, -1, +1);
|
||||||
|
}
|
||||||
|
if (y >= (yprd - cutneigh) && z >= (zprd - cutneigh)) {
|
||||||
|
ADDGHOST(0, -1, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->pbc_x != 0 && param->pbc_y != 0) {
|
||||||
|
if (y < cutneigh && x < cutneigh) {
|
||||||
|
ADDGHOST(+1, +1, 0);
|
||||||
|
}
|
||||||
|
if (y < cutneigh && x >= (xprd - cutneigh)) {
|
||||||
|
ADDGHOST(-1, +1, 0);
|
||||||
|
}
|
||||||
|
if (y >= (yprd - cutneigh) && x < cutneigh) {
|
||||||
|
ADDGHOST(+1, -1, 0);
|
||||||
|
}
|
||||||
|
if (y >= (yprd - cutneigh) && x >= (xprd - cutneigh)) {
|
||||||
|
ADDGHOST(-1, -1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// increase by one to make it the ghost atom count
|
||||||
|
atom->Nghost = Nghost + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* internal subroutines */
|
||||||
|
void growPbc(Atom* atom)
|
||||||
|
{
|
||||||
|
int nold = nmaxGhost;
|
||||||
|
nmaxGhost += DELTA;
|
||||||
|
|
||||||
|
atom->border_map = (int*)reallocate(atom->border_map,
|
||||||
|
ALIGNMENT,
|
||||||
|
nmaxGhost * sizeof(int),
|
||||||
|
nold * sizeof(int));
|
||||||
|
PBCx = (int*)reallocate(PBCx, ALIGNMENT, nmaxGhost * sizeof(int), nold * sizeof(int));
|
||||||
|
PBCy = (int*)reallocate(PBCy, ALIGNMENT, nmaxGhost * sizeof(int), nold * sizeof(int));
|
||||||
|
PBCz = (int*)reallocate(PBCz, ALIGNMENT, nmaxGhost * sizeof(int), nold * sizeof(int));
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||||
* All rights reserved. This file is part of MD-Bench.
|
* All rights reserved. This file is part of MD-Bench.
|
||||||
* Use of this source code is governed by a LGPL-3.0
|
* Use of this source code is governed by a LGPL-3.0
|
||||||
* license that can be found in the LICENSE file.
|
* license that can be found in the LICENSE file.
|
Loading…
Reference in New Issue
Block a user