Skip to content

Commit

Permalink
Make sopt/popt aliases for ssmp/psmp with OMP_NUM_THREADS=1
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Jun 11, 2020
1 parent 1e4446c commit 2902a7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,18 @@ $(EXE_NAMES) all toolversions extversions extclean libcp2k cp2k_shell exts $(EXT

# stage 2: Store the version target in $(ONEVERSION),
# Call make recursively with $(ORIG_TARGET) as target.
$(VERSION) :
$(filter-out sopt, popt, $(VERSION)) :
@+$(MAKE) --no-print-directory -f $(MAKEFILE) $(ORIG_TARGET) ORIG_TARGET="" VERSION="" ONEVERSION=$@

sopt:
@+echo "Version sopt is now an alias for ssmp with OMP_NUM_THREADS=1."
@+$(MAKE) --no-print-directory -f $(MAKEFILE) $(ORIG_TARGET) ORIG_TARGET="" VERSION="" ONEVERSION="ssmp"
cd $(EXEDIR); ln -sf cp2k.ssmp cp2k.sopt
popt:
@+echo "Version popt is now an alias for psmp with OMP_NUM_THREADS=1."
@+$(MAKE) --no-print-directory -f $(MAKEFILE) $(ORIG_TARGET) ORIG_TARGET="" VERSION="" ONEVERSION="psmp"
cd $(EXEDIR); ln -sf cp2k.psmp cp2k.popt

else

# stage 3: Include arch-file, create dirs, and run makedep.py for given $(ONEVERSION).
Expand Down
9 changes: 8 additions & 1 deletion src/start/cp2k.F
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
! **************************************************************************************************
PROGRAM cp2k

USE OMP_LIB, ONLY: omp_set_num_threads
USE cp2k_info, ONLY: compile_revision,&
cp2k_flags,&
cp2k_version,&
Expand Down Expand Up @@ -98,7 +99,7 @@ PROGRAM cp2k
ALLOCATE (initial_variables(2, 1:0))

! get command and strip path
CALL GET_COMMAND(command, status=ierr)
CALL GET_COMMAND_ARGUMENT(0, command, status=ierr)
CPASSERT(ierr == 0)
l = LEN_TRIM(command)
DO i = l, 1, -1
Expand All @@ -116,6 +117,12 @@ PROGRAM cp2k
command_line_error = .TRUE.
END IF

! check if binary was invoked as sopt or popt alias
l = LEN_TRIM(command)
IF (command(l - 4:l) == ".sopt" .OR. command(l - 4:l) == ".popt") THEN
CALL omp_set_num_threads(1)
ENDIF

i_arg = 0
arg_loop: DO WHILE (i_arg < COMMAND_ARGUMENT_COUNT())
i_arg = i_arg + 1
Expand Down

0 comments on commit 2902a7c

Please sign in to comment.